diff --git a/src/polyfills/array-includes.js b/src/polyfills/array-includes.js index 121ab5e14dd9..c1a16aef5024 100644 --- a/src/polyfills/array-includes.js +++ b/src/polyfills/array-includes.js @@ -44,6 +44,11 @@ function includes(value, opt_fromIndex) { */ export function install(win) { if (!win.Array.prototype.includes) { - win.Array.prototype.includes = includes; + win.Object.defineProperty(Array.prototype, 'includes', { + enumerable: false, + configurable: true, + writable: true, + value: includes, + }); } } diff --git a/src/polyfills/document-contains.js b/src/polyfills/document-contains.js index c2ebe6542c01..7054a7c4f739 100644 --- a/src/polyfills/document-contains.js +++ b/src/polyfills/document-contains.js @@ -37,6 +37,11 @@ function documentContainsPolyfill(node) { */ export function install(win) { if (!win.HTMLDocument.prototype.contains) { - win.HTMLDocument.prototype.contains = documentContainsPolyfill; + win.Object.defineProperty(win.HTMLDocument.prototype, 'contains', { + enumerable: false, + configurable: true, + writable: true, + value: documentContainsPolyfill, + }); } } diff --git a/src/polyfills/domtokenlist-toggle.js b/src/polyfills/domtokenlist-toggle.js index dde0161f9eb2..b037e2a85116 100644 --- a/src/polyfills/domtokenlist-toggle.js +++ b/src/polyfills/domtokenlist-toggle.js @@ -42,7 +42,12 @@ function domTokenListTogglePolyfill(token, opt_force) { */ export function install(win) { if (isIe(win) && win.DOMTokenList) { - win.DOMTokenList.prototype.toggle = domTokenListTogglePolyfill; + win.Object.defineProperty(win.DOMTokenList.prototype, 'toggle', { + enumerable: false, + configurable: true, + writable: true, + value: domTokenListTogglePolyfill, + }); } } diff --git a/src/polyfills/math-sign.js b/src/polyfills/math-sign.js index bd20cafda9d5..1c16daab79a2 100644 --- a/src/polyfills/math-sign.js +++ b/src/polyfills/math-sign.js @@ -40,6 +40,11 @@ export function sign(x) { */ export function install(win) { if (!win.Math.sign) { - win.Math.sign = sign; + win.Object.defineProperty(win.Math, 'sign', { + enumerable: false, + configurable: true, + writable: true, + value: sign, + }); } } diff --git a/src/polyfills/object-assign.js b/src/polyfills/object-assign.js index dcc1ffdfc034..d64838d22bb9 100644 --- a/src/polyfills/object-assign.js +++ b/src/polyfills/object-assign.js @@ -50,6 +50,11 @@ export function assign(target, var_args) { */ export function install(win) { if (!win.Object.assign) { - win.Object.assign = assign; + win.Object.defineProperty(win.Object, 'assign', { + enumerable: false, + configurable: true, + writable: true, + value: assign, + }); } } diff --git a/test/functional/test-polyfill-document-contains.js b/test/functional/test-polyfill-document-contains.js index 6f447cde83e4..e66516a092f4 100644 --- a/test/functional/test-polyfill-document-contains.js +++ b/test/functional/test-polyfill-document-contains.js @@ -37,12 +37,14 @@ describe('HTMLDocument.contains', () => { HTMLDocument: class { contains() {} }, + Object: window.Object, }; nativeContains = fakeWinWithContains.HTMLDocument.prototype.contains; fakeWinWithoutContains = { HTMLDocument: class { }, + Object: window.Object, }; install(fakeWinWithoutContains); polyfillContains = fakeWinWithoutContains.HTMLDocument.prototype.contains;