-
Notifications
You must be signed in to change notification settings - Fork 4
fix #60 - writable for polyfilled properties #61
Conversation
@@ -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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be a more robust check to do something like:
if (memberProperty.hasOwnProperty('value')) {
memberProperty.writable = true
}
Or something. I think the only one's we care about making writable are the ones we specify a hard value
for. The ones we don't want to be writable we're specifying using the staticProp()
function that uses Object.defineProperty()
.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree :)
Is there a test we should write for this? |
Don't know, maybe. |
Yeah, could write a test to see if we can override methods. |
lgtm |
@@ -53,6 +53,13 @@ describe('shadow/polyfill', function () { | |||
}); | |||
} | |||
|
|||
it('polyfilled properties with value should be writable', function() { | |||
let elem = create('div'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could be const
, but nitpick :)
LGTM |
The problem is connected to the #41
Since jQuery uses assignment for removeEventListener in tests