From dbd2632da97fd08fbd2c7e0ad0ec8e2bd08918fe Mon Sep 17 00:00:00 2001 From: Nadia Makarevich Date: Tue, 3 May 2016 11:18:29 +1000 Subject: [PATCH 1/2] fix #60 - writable for polyfilled properties --- src/index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/index.js b/src/index.js index b8e4d24..d755543 100644 --- a/src/index.js +++ b/src/index.js @@ -749,6 +749,8 @@ if (!('attachShadow' in document.createElement('div'))) { // All properties should be configurable. memberProperty.configurable = true; + // Applying to the data properties only since we can't have writable accessor properties + !(memberProperty.hasOwnProperty('get') || memberProperty.hasOwnProperty('set')) && (memberProperty.writable = true); // Polyfill as much as we can and work around WebKit in other areas. if (canPatchNativeAccessors || polyfillAtRuntime.indexOf(memberName) === -1) { From be4903e0e9aa0da2cdda645d98d049622f3701fd Mon Sep 17 00:00:00 2001 From: Nadia Makarevich Date: Tue, 3 May 2016 15:25:06 +1000 Subject: [PATCH 2/2] fix #60 - add test --- src/index.js | 4 +++- test/unit/shadow/polyfill.js | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index d755543..7cf0ff9 100644 --- a/src/index.js +++ b/src/index.js @@ -750,7 +750,9 @@ if (!('attachShadow' in document.createElement('div'))) { // All properties should be configurable. memberProperty.configurable = true; // Applying to the data properties only since we can't have writable accessor properties - !(memberProperty.hasOwnProperty('get') || memberProperty.hasOwnProperty('set')) && (memberProperty.writable = true); + if (memberProperty.hasOwnProperty('value')) { + memberProperty.writable = true + } // Polyfill as much as we can and work around WebKit in other areas. if (canPatchNativeAccessors || polyfillAtRuntime.indexOf(memberName) === -1) { diff --git a/test/unit/shadow/polyfill.js b/test/unit/shadow/polyfill.js index e726ed9..6ba3cc5 100644 --- a/test/unit/shadow/polyfill.js +++ b/test/unit/shadow/polyfill.js @@ -53,6 +53,13 @@ describe('shadow/polyfill', function () { }); } + it('polyfilled properties with value should be writable', function() { + let elem = create('div'); + + expect(elem.removeEventListener).not.to.equal(""); + elem.removeEventListener = ""; + expect(elem.removeEventListener).to.equal(""); + }); describe('api', function () { let host, root;