MCPcopy Create free account
hub / github.com/ampproject/amphtml / constructor

Method constructor

testing/fake-dom.js:679–701  ·  view source on GitHub ↗

@param {!Window} win

(win)

Source from the content-addressed store, hash-verified

677export class FakeCustomElements {
678 /** @param {!Window} win */
679 constructor(win) {
680 /** @const */
681 this.win = win;
682
683 /** @type {number} */
684 this.count = 0;
685
686 /** @const {!{[key: string]: !{prototype: !Prototype}}} */
687 this.elements = {};
688
689 /**
690 * Custom Elements V0 API.
691 * @param {string} name
692 * @param {{prototype: !Prototype}} spec
693 */
694 this.win.document.registerElement = (name, spec) => {
695 if (this.elements[name]) {
696 throw new Error('custom element already defined: ' + name);
697 }
698 this.elements[name] = spec;
699 this.count++;
700 };
701 }
702
703 /**
704 * Custom Elements V1 API.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected