-
Notifications
You must be signed in to change notification settings - Fork 31
Allows to pass to reactify the tagName instead of the CustomElement #38
Conversation
…lass Avoids creating an instance of the component just to get the tagName. Makes it possible to use this with Web.Components written in TypeScript.
Can you add a test for this? |
This only work with custom element V1. I don't know how to add custom element V1 this to the test. describe('reactify-with-tag-name', () => {
}); |
I think your test looks good. Also it doesn't look like it's just for typescript? It's pretty generic ( |
I agree it is very generic but, customElement V1 or a customElement V1 polyfill must be in place. |
var tagName; | ||
if (typeof CustomElement === 'string') { | ||
tagName = CustomElement; | ||
CustomElement = customElements.get(tagName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm probably missing something, but how does this work? Where is customElements.get
defined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's on window - but do we fill that cross-browser @treshugart ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's on window
Yeah, because window
. It's still probably good to do a const { customElements } = window;
at the top.
but do we fill that cross-browser
We don't, no. This was part of the reason that we opted to just use the constructor in the beginning.
@andreawyss you can import https://github.com/skatejs/web-components to the package.json and then import it in the main test entry point ( I've thought about doing this in the past but decided against it for a couple reasons:
There's currently no spec on how to get the I've raised an issue and a modest proposal in WICG/webcomponents#566 for doing this without having to construct the element. Any counter arguments? Thoughts? This really feels like something TypeScript needs to fix, however, including the polyfill might fix it. |
I agree that this is just a workaround for a TypeScript bug. Therefore I will Close this PR. |
Awesome! Thanks, @andreawyss! |
Allows to pass to reactify the tagName instead of the CustomElement class.
Avoids creating an instance of the component just to get the tagName.
Makes it possible to use this with Web.Components written in TypeScript.