How to extend an existing custom item?

I have a custom element called x-foo. I would like to expand it and create an element x-foo-extended, but it does not work. I get this error:

Uncaught NotSupportedError: Failed to execute 'registerElement' in 'Document': Registration error for type 'x-foo-extended'. The tag name specified in 'extends' is the name of the user element. Use inheritance instead.

    var xFooExtendedProto = Object.create(xFoo.prototype);

    xFooExtendedProto.someCustomFunc = function() {
        // ...
    };

    xFooExtended = document.registerElement('x-foo-extended', {
        prototype: xFooExtendedProto,
        extends: 'x-foo'
    });
+3
source share
1 answer
+3

Source: https://habr.com/ru/post/1673470/


All Articles