Skip to content
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

Added support for extending HTMLElement #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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.

None yet

2 participants