Skip to content

Conversation

oravecz
Copy link

@oravecz oravecz commented Jan 5, 2017

Added a third parameter to Reflect.construct() which was preventing the plugin from working with classes that extend HTMLElement

I would like to contribute a test, but that would be a lot of work considering the tests do not currently support a browser environment. If someone wants to add that plumbing, they can use this test. It will have to be run in Chrome unless polyfills are provided. Not sure if Phantom supports it or not.

    describe('HTMLElement', function(){
        class MyHTMLElement extends HTMLElement {
            constructor(){
                super();
                this.attr = null;
            }

            static get observedAttributes() {
                return [ 'supports' ]
            }

            attributeChangedCallback( name, oldValue, newValue ) {
                if (name === 'supports') {
                    this.attr = newValue;
                }
            }
        }

        it('should behave properly', function(){
            const a = new MyHTMLElement();
            a.setAttribute('supports', 'HTMLElement');

            expect(a instanceof MyHTMLElement).to.be.true;
            expect(a instanceof HTMLElement).to.be.true;

            expect(a).to.have.ownProperty('offsetLeft');
            expect(a).to.have.ownProperty('attr');

            expect(a.attr).to.eql('HTMLElement');
        });
    });

…he plugin from working with classes that extend HTMLElement
@aaronshaf
Copy link

@loganfsmyth this would be 👍 wonderful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants