Skip navigation
We have Custom Elements, but do we also need Custom Attributes?
0:00 / 1:49

We have Custom Elements, but do we also need Custom Attributes?

Firefox for Web Developers

@FirefoxWebDevs90K followers

Visit on X
59 likesDownloadOriginal post

23,810 views

We have Custom Elements, but do we also need Custom Attributes? This was discussed at TPAC. Is it something you'd like on the platform?

11 Comments

Comments from the original post on X (Twitter)

  • Firefox for Web Developers's profile picture

    @FirefoxWebDevs

    More details about the proposal on GitHub

    9 likes

  • Geoff Goodman's profile picture

    @filearts

    This reminds me a lot of AngularJS directives. These were tricky but powerful tools for composable behavior. They were used sparingly but couldn't be replicated with other APIs. Could the hypothetical API allow a my-for attribute that manages a set of cloned instances?

    4 likes

  • FireNeslo's profile picture

    @FireNeslo

    Yes finally we can add the mythical customAttributes.define('is', CustomElementExtendsAttribute)

    4 likes

  • JLarky's profile picture

    @JLarky

    I'm glad to see that web components hype died down enough for standalone features like scoped css and custom attributes to finally get some attention!

    4 likes

  • Leni Riefensituations's profile picture

    @olaf_k

    @jaffathecake I’d argue custom attributes would be far more powerful than custom elements!

    1 like

  • Artem Zakharchenko's profile picture

    @kettanaito

    Not sure I like the idea of a custom attribute mutating a built-in HTML element. That obscures the discovery of that custom behavior or even makes it impossible if your custom attribute it set programmatically/dynamically. Not sure what problem custom attrs solve.

    1 like

  • Sergei Garin 🇷🇺's profile picture

    @MrFlashAccount

    Are you discussing things like accessing popover/dialog API without using corresponding attributes/tags?

    1 like

  • Robbie Speed's profile picture

    @RobbieSpeed

    Yes, want very much, but do not want them to override or create any accessors and methods on assigned elements. That stuff should all live on the attribute node itself.

  • Victor Gbaye's profile picture

    @victorgbaye

    I’m not sure this is a great idea, think browser compatibility and accessibility.

  • Praveen Ponnusamy's profile picture

    @prav33n

    Would be definitely useful for custom elements. 👍 Not sure about all elements - sounds like a can of worms.

  • Marco Siedentopf's profile picture

    @siematos

    I like the idea of encoding more in HTML. But please don't go the CustomElements/ShadowDOM route. Think about how to define and register behavior declaratively first please. At a minimum, this involves integration into CSS queries/selectors in a <noscript>/lynx environment.