Shadow DOM in use in React

1. Shadow DOM is what

What Shadow DOM that? Let's open the Chrome DevTool, and in 'Settings -> Preferences -> Elements' in the 'Show user agent shadow DOM' tick. Then, open a support HTML5 video playback website. For example, Youtube:

image.png
You can see video has an internal #shadow-root , you can still see under ShadowRoot div such common HTML tags. We know video there will be "Play / Pause button, progress bar, video time display, volume control," and other controls, and that in fact, is made in these sub-elements ShadowRoot constituted. The most commonly used input is actually attached Shadow DOM, for example, we give a try in Chrome


Guess you like

Origin yq.aliyun.com/articles/717933