-
-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
can't extend HTMLElement #7
Comments
Is it possible to post the exception and what browser was used? |
Oh, it's happening (at least) on Chrome, with the exception in mini.js in the stubChain function:
Chain[0] is the HTMLElement, and you can reproduce the root of the problem in the console:
|
I looked into that. The problem is that HTMLElement is:
Obviously, it is possible to accommodate such constructs, the real question is how? Treat it as a special case? Create a registry for founding "classes" like that? Do we need to add a special helper, which will automatically register such "classes" with a document? I am leaning towards a registry with HTMLElement and related "classes" pre-registered, framed as a separate HTML-specific module added on demand, but if you guys have better ideas, I would be glad to hear them. PS: A side note: what Polymer guys were thinking bypassing normal JavaScript ways to do things? My guess: they complained about restrictiveness of existing implementations, which they decided to enshrine for a foreseeable future. :-( |
I guess any of those options would work. A registry sounds fine. Another approach is to ignore "Illegal constructor" TypeErrors altogether. You'd need a try/catch around each constructor call though so it might affect performance. You could also build a "registry" on the fly by checking each constructor the first time you see it. Note that with web components we will never call BTW for some reason this isn't an issue with ComposeJS, so you might want to check why it works there. |
IIRC ComposeJS does not chain constructors automatically, so it is never called. |
Cool, looks like you fixed this in your 1.1 release; that the dcl() call runs without an error. For the record, my updated test case is:
|
I still have to check if it is enough. |
OK. Well anyway it seems to be working for us (see latest code on https://github.com/ibm-dojo/dui) Incidentally I worked around the lack of native accessor support by implementing it myself in our Stateful class. |
You cannot create a class that extends HTMLElement. This precludes using DCL to create web components (see the "Basic usage" section of http://www.polymer-project.org/platform/custom-elements.html).
A simple test case (to be placed in the dcl/tests directory) is:
It will hit an exception and pause in the browser's debugger, assuming that the debugger is open.
Cc @kitsonk who originally mentioned this issue.
The text was updated successfully, but these errors were encountered: