- From: Mike Collins <notifications@github.com>
- Date: Tue, 24 Oct 2017 20:20:25 +0000 (UTC)
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/dom/issues/522/339118581@github.com>
https://w3c.github.io/webcomponents/spec/custom/#custom-element-conformance When authoring custom element constructors, authors are bound by the following conformance requirements: - A parameter-less call to super() must be the first statement in the constructor body, to establish the correct prototype chain and this value before any further code is run. - A return statement must not appear anywhere inside the constructor body, unless it is a simple early-return (return or return this). - The constructor must not use the document.write() or document.open() methods. - The element's attributes and children must not be inspected, as in the non-upgrade case none will be present, and relying on upgrades makes the element less usable. - The element must not gain any attributes or children, as this violates the expectations of consumers who use the createElement or createElementNS methods. - In general, work should be deferred to connectedCallback as much as possible—especially work involving fetching resources or rendering. However, note that connectedCallback can be called more than once, so any initialization work that is truly one-time will need a guard to prevent it from running twice. - In general, the constructor should be used to set up initial state and default values, and to set up event listeners and possibly a shadow root. Several of these requirements are checked during element creation, either directly or indirectly, and failing to follow them will result in a custom element that cannot be instantiated by the parser or DOM APIs. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/whatwg/dom/issues/522#issuecomment-339118581
Received on Tuesday, 24 October 2017 20:20:51 UTC