Web Components - why <content> was replaced with <slot>

 ̄綄美尐妖づ 提交于 2019-12-22 06:55:47

问题


Version 1.0 of Shadow DOM will completely replace the <content> tag with <slot>. There are examples on the web I cannot find a relevant discussion which justifies this change.

What was the problem with <content>, which <slot> will solve? After all the new design is completely different.


回答1:


The editor of Shadow DOM specification is here.

It would be difficult to summarize the reason here, however, the following discussions and the minutes might be helpful to understand the history and the reason:

  • https://lists.w3.org/Archives/Public/public-webapps/2015AprJun/thread.html#msg184
  • https://www.w3.org/wiki/Webapps/WebComponentsApril2015Meeting (See "F. Slots Proposal")
  • https://lists.w3.org/Archives/Public/public-webapps/2015AprJun/thread.html#msg649

Yeah, Google opposed to this change at first, but we had no other choice to make Shadow DOM forward. :)

I have rewritten Shadow DOM specification as "v1" so that it will be the standard on which all browser vendors could agree. That's the primary reason.

We all are aware that the API change is painful for Web developers, but I believed that "Native Shadow DOM in every browsers" is much important for the Web platform in the long term.

See also here for other changes between v0 and v1:



来源:https://stackoverflow.com/questions/38540025/web-components-why-content-was-replaced-with-slot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!