MCPcopy Index your code
hub / github.com/nodejs/node / defineCustomElement

Method defineCustomElement

deps/v8/tools/js/web-api-helper.mjs:277–294  ·  view source on GitHub ↗
(
      path, nameOrGenerator, maybeGenerator = undefined)

Source from the content-addressed store, hash-verified

275 }
276
277 static defineCustomElement(
278 path, nameOrGenerator, maybeGenerator = undefined) {
279 let generator = nameOrGenerator;
280 let name = nameOrGenerator;
281 if (typeof nameOrGenerator == 'function') {
282 console.assert(maybeGenerator === undefined);
283 name = path.substring(path.lastIndexOf('/') + 1, path.length);
284 } else {
285 console.assert(typeof nameOrGenerator == 'string');
286 generator = maybeGenerator;
287 }
288 path = path + '-template.html';
289 fetch(path)
290 .then(stream => stream.text())
291 .then(
292 templateText =>
293 customElements.define(name, generator(templateText)));
294 }
295}

Callers 15

code-panel.mjsFile · 0.80
map-panel.mjsFile · 0.80
profiler-panel.mjsFile · 0.80
script-panel.mjsFile · 0.80
list-panel.mjsFile · 0.80
tool-tip.mjsFile · 0.80
timeline-panel.mjsFile · 0.80

Calls 5

fetchFunction · 0.85
assertMethod · 0.80
textMethod · 0.65
generatorFunction · 0.50
thenMethod · 0.45

Tested by

no test coverage detected