* 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)
| 951 | * @return {!AmpElement} |
| 952 | */ |
| 953 | function 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 | } |
nothing calls this directly
no test coverage detected