Vanilla JavaScript Пользовательские элементы TypeError - PullRequest
0 голосов
/ 27 сентября 2018

Мой вопрос касается расширения HTMLElement для пользовательского элемента.

class Foo extends HTMLElement { ... }

class Bar extends Foo { ... }

class FooBar extends Bar { ... }

Каждый из них вызывает super () в конструкторе.

Когда я определяю пользовательский элемент с помощью Bar, я не надеваюЯ не получаю никакой ошибки

customElements.define( 'custom-tag', Bar );
or
customElements.define( 'custom-tag', class Bar extends Foo { ... } );

Я пытаюсь определить пользовательский элемент, используя класс FooBar.

customElements.define( 'other-custom-tag', FooBar );
or
customElements.define( 'other-custom-tag', class FooBar extends Bar { ... } );

Но я получаю

Uncaught TypeError: Failed to execute 'define' on 'CustomElementRegistry':
The provided value cannot be converted to a sequence.

Via Mozilla Docs

https://developer.mozilla.org/en-US/docs/Web/API/CustomElementRegistry/define

TypeError   The referenced constructor is not a constructor.

Я не смог найти ничего подходящего для этой проблемы ...

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...