MCPcopy Index your code
hub / github.com/ampproject/amphtml / constructor

Method constructor

src/core/context/node.js:180–279  ·  view source on GitHub ↗

* Creates the context node and automatically starts the discovery process. * * @param {Node} node * @param {?string} name

(node, name)

Source from the content-addressed store, hash-verified

178 * @param {?string} name
179 */
180 constructor(node, name) {
181 /**
182 * @const
183 * @type {Node}
184 */
185 this.node = node;
186
187 /**
188 * @const
189 * @package
190 * @type {?string}
191 */
192 this.name = name;
193
194 /**
195 * Whether this node is a root. The Document DOM nodes are automatically
196 * considered as roots. But other nodes can become roots as well
197 * (e.g. shadow roots) via `setIsRoot()` API.
198 *
199 * @package
200 * @type {boolean}
201 */
202 this.isRoot = node.nodeType == DOCUMENT_NODE;
203
204 /**
205 * The root context node. Always available for a DOM node connected to a
206 * root node after the discovery phase.
207 *
208 * @package
209 * @type {?ContextNode<?>}
210 */
211 this.root = this.isRoot ? this : null;
212
213 /**
214 * Parent should be mostly meaningless to most API clients, because
215 * it's an async concept: a parent context node can can be instantiated at
216 * any time and it doesn't mean that this node has to change. This is
217 * why the API is declared as package-private. However, it needs to be
218 * unobfuscated to avoid cross-binary issues.
219 *
220 * @package
221 * @type {?ContextNode<?>}
222 */
223 this.parent = null;
224
225 /**
226 * See `parent` description.
227 *
228 * @package
229 * @type {?ContextNode<?>[]}
230 */
231 this.children = null;
232
233 /**
234 * @package
235 * @type {?Map<string, GroupDef>}
236 */
237 this.groups = null;

Callers

nothing calls this directly

Calls 5

discoverMethod · 0.95
throttleTailFunction · 0.90
closestMethod · 0.80
addEventListenerMethod · 0.45
forEachMethod · 0.45

Tested by

no test coverage detected