x-tag / core

The Heart of X-Tag
http://x-tag.github.io/
Other
1.25k stars 151 forks source link

Version 1.5.7 broke my application #152

Closed VsLoureiro closed 8 years ago

VsLoureiro commented 8 years ago

Hi,

Since version 1.5.7, my application does not run anymore and I had to go back to version 1.5.6.

The error is: Uncaught TypeError: Illegal invocation

in line 9129 of x-tag-core.js file

csuwildcat commented 8 years ago

Can you provide any further details on this?

csuwildcat commented 8 years ago

Can you trace the error from the library to the part in your code it's coming from so I have a better idea what kind of use is triggering it?

VsLoureiro commented 8 years ago

This is the code that triggers it:

xtag.register('custom-element', { prototype: Object.create(HTMLDivElement.prototype) });

csuwildcat commented 8 years ago

So we introduced a breaking change, but the good news is that it was to simplify things: Elements that don't extend natives are automatically prototyped with HTMLElement for you. This means you don't need to add the prototype property at all for the code snippet you pasted here.

Another note: in the final, standard registerElement API, you can only use HTMLElement prototype unless you're truly extending a native (via the is= syntax and the extends definition property), so your code here is technically invalid. Here's what it would need to look like to be valid:

xtag.register('custom-element', { extends: 'div' });

And to use it:

If you're not actually attempting to extend the DIV element and just want a truly custom tag, you don't need to specify a prototype or extends property at all:

xtag.register('custom-element', {

});

To use:

On May 13, 2016 5:49 AM, "Vitor Loureiro" notifications@github.com wrote:

This is the code that triggers it:

xtag.register('custom-element', { prototype: Object.create(HTMLDivElement.prototype) });

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/x-tag/core/issues/152#issuecomment-219033440

VsLoureiro commented 8 years ago

Thank you! It works now.

We only had that for our oldest components, for the new one we don't use the prototype property.

Cheers

csuwildcat commented 8 years ago

@VsLoureiro I have a new build up on master that extends the reach of inheritance/composition to mixins and other features. Do you mind grabbing the dist or core on master and testing against your code to ensure we are not breaking anything? All our tests pass currently.