Skip to content

Customized built-in elements uses old and incorrect example. #44952

Description

@Kaiido

MDN URL

https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_custom_elements

What specific section or headline is this issue about?

The "Customized built-in elements" section.

What information was incorrect, unhelpful, or incomplete?

This section still refers to an old version of the example that did uselessly define a constructor, and harmfully override the global self.
Note that even if it wasn't the globalThis.self and instead a variable defined near the class definition, it would still be wrong since this variable would only ever refer to the latest instance created, shadowing all the previous instances.
The example's source actually got updated in mdn/web-components-examples#81.

What did you expect to see?

An article explaining how the new (more correct) example works, with no use of a self trick since this is the proper way to handle that.

Do you have any supporting links, references, or citations?

mdn/web-components-examples#81

Do you have anything more you want to share?

No response

MDN metadata

Page report details

Metadata

Metadata

Assignees

No one assigned

    Labels

    Content:WebAPIWeb API docsneeds triageTriage needed by staff and/or partners. Automatically applied when an issue is opened.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions