Created
January 16, 2019 15:48
-
-
Save SergioLarios/c57090bf44371bacea05d61907bb6deb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Ayuda con la compilacion en es5 de typescript ya que si no da un error | |
// https://stackoverflow.com/a/41671440 | |
// https://github.com/webcomponents/custom-elements/blob/master/src/native-shim.js | |
(function() { | |
if ( | |
// No Reflect, no classes, no need for shim because native custom elements | |
// require ES2015 classes or Reflect. | |
(<any>window).Reflect === undefined || | |
window.customElements === undefined || | |
// The webcomponentsjs custom elements polyfill doesn't require | |
// ES2015-compatible construction (`super()` or `Reflect.construct`). | |
window.customElements.hasOwnProperty('polyfillWrapFlushCallback') | |
) { | |
return; | |
} | |
const BuiltInHTMLElement = HTMLElement; | |
(<any>window).HTMLElement = /** @this {!Object} */ function HTMLElement() { | |
return Reflect.construct( | |
BuiltInHTMLElement, [], /** @type {!Function} */ (this.constructor)); | |
}; | |
HTMLElement.prototype = BuiltInHTMLElement.prototype; | |
HTMLElement.prototype.constructor = HTMLElement; | |
Object.setPrototypeOf(HTMLElement, BuiltInHTMLElement); | |
})(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment