问题
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