WICG / proposals

A home for well-formed proposed incubations for the web platform. All proposals welcome.
https://wicg.io/
Other
230 stars 14 forks source link

Evolution of DOM API to a higher level of abstraction. #22

Open alejsanc opened 3 years ago

alejsanc commented 3 years ago

I think it would be convenient for the DOM API to evolve to a higher level of abstraction as some Javascript libraries allow with high level and chainable methods.

Example:

 paragraph.appendElement("a").setAttribute("href", "/article");

I have made this same proposition in whatwg-dom and have been recommended to do it here.

myakura commented 3 years ago

fyi https://discourse.wicg.io/t/declarative-ish-javascript-api-for-creating-dom/2641

alejsanc commented 3 years ago

fyi https://discourse.wicg.io/t/declarative-ish-javascript-api-for-creating-dom/2641

in that conversation they seem to be more interested in creating the document declaratively. That the "append" method returns "this" is just one way to achieve that goal. I would like to focus more not only on the "append" method returning "this" but also on having methods like "appendElement (String tag)".

in that conversation the following is given as an example:

document.body.append(
     document.createElement('div').append(
          document.createElement('span').append(
               'hello'
          ),

I think that should be done in the following way:

document.body.appendElement("div").appendElement("span").appendText("hello").

It seems to me that this is very simple and could be included in the DOM API easily

yoavweiss commented 6 months ago

Hey! The chairs noticed that this hasn't seen any recent activity and it doesn't seem like this got any implementation traction. For this kind of a proposal to move forward, it'd be good to get broader community support and implementation champions on board.

Adding a "looking for interest" label.