什么时候 WebComponent 被采纳回调触发? [英] When does WebComponent adoptedCallback fire?

查看:19
本文介绍了什么时候 WebComponent 被采纳回调触发?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 MDN 文档中,我看到 WebComponents 可以实现一个名为 adoptedCallback 的函数.MDN 文档说明:

On MDN documentation, I see a function that WebComponents can implement called adoptedCallback. MDNs documentation states:

在自定义元素移动到新文档时调用."

"Invoked when the custom element is moved to a new document."

https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements

https://github.com/w3c/webcomponents/issues/512

自定义元素已移至新文档是什么意思?在什么情况下我应该实施这个?

What does it mean that the custom element has moved to a new document? Under what circumstances should I implement this?

推荐答案

adoptedCallback() 方法在自定义元素从一个 HTML 文档移动到另一个带有 adoptNode() 方法.

The adoptedCallback() method is called when a Custom Element is moved from one HTML document to another one with the adoptNode() method.

当您的页面中有