A partial archive of discourse.wicg.io as of Saturday February 24, 2024.

Which elements forward instance props to attributes, and which don’t?

trusktr
2018-07-30

For example, the img element forwards the the src prop onto the src attribute, as in I can write

document.querySelector('img').src = 'foo.png'

and then this will set the attribute.

Are there elements that don’t get their props forwarded to attributes?

Where can I see a list of which elements forward, and which don’t?

myakura
2018-08-03

In HTML, it is said that some IDL attributes (properties) “reflect” their corresponding content attributes (HTML attributes). https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#reflect

I don’t think there is a list for such. If you search for “IDL attribute must reflect the” you kinda get which properties reflect content attributes.

Some other properties, however, are not simply reflect content attributes. For instance, the href property on the a and link elements need to get serialized URLs so the spec defines “set the URL” and “update” algorithms. In such cases you cannot simply search. https://html.spec.whatwg.org/multipage/links.html#update-href https://html.spec.whatwg.org/multipage/links.html#concept-hyperlink-url-set