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

Function createAmpElement

testing/describes.js:953–972  ·  view source on GitHub ↗

* Creates a custom element without registration. * @param {!Window} win * @param {string=} opt_name * @param {typeof ./base-element.BaseElement} opt_implementationClass * @return {!AmpElement}

(win, opt_name, opt_implementationClass)

Source from the content-addressed store, hash-verified

951 * @return {!AmpElement}
952 */
953function createAmpElement(win, opt_name, opt_implementationClass) {
954 // Create prototype and constructor.
955 const name = opt_name || 'amp-element';
956 const proto = createAmpElementForTesting(win).prototype;
957 const ctor = function () {
958 const el = win.document.createElement(name);
959 el.__proto__ = proto;
960 return el;
961 };
962 ctor.prototype = proto;
963 proto.constructor = ctor;
964
965 // Create the element instance.
966 const element = new ctor();
967 element.implementationClassForTesting =
968 opt_implementationClass || BaseElement;
969 element.createdCallback();
970 element.classList.add('i-amphtml-element');
971 return element;
972}

Callers

nothing calls this directly

Calls 3

createdCallbackMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected