whatwg / dom

DOM Standard
https://dom.spec.whatwg.org/
Other
1.58k stars 295 forks source link

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

Closed alejsanc closed 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");
WebReflection commented 3 years ago

FWIW, this works already

const a = document.createElement('a');
paragraph.appendChild(a).setAttribute("href", "/article");

alternatives for more than a single attribute exist too:

Object.assign(
  paragraph.appendChild(document.createElement('a')),
  {
    href: '/article',
    title: 'cool article'
  }
);
alejsanc commented 3 years ago

Those examples that you put are more complex than my example. That's why people use libraries and not the DOM directly.

annevk commented 3 years ago

Hey @alejsanc, thanks for your interest in improving the DOM Standard. I recommend working with the https://wicg.io/ community to turn this into a concrete proposal we can evaluate.

alejsanc commented 3 years ago

Thanks for the info annevk.