Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
Add workaround for broken Safari 8 DOM
Browse files Browse the repository at this point in the history
Safari's DOM is broken. It is returns invalid descriptors. We therefore
treat all properties as read-write even if they are really read only.

Fixes https://github.com/Polymer/platform/issues/66
  • Loading branch information
arv committed Sep 9, 2014
1 parent 565b978 commit cfaa850
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/wrappers.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,15 @@ window.ShadowDOMPolyfill = {};
}
}

// Safari 8 exposes WebIDL attributes as an invalid accessor property. Its
// descriptor has {get: undefined, set: undefined}. We therefore ignore the
// shape of the descriptor and make all properties read-write.
// https://bugs.webkit.org/show_bug.cgi?id=49739
var isBrokenSafari = function() {
var descr = Object.getOwnPropertyDescriptor(Node.prototype, 'nodeType');
return !!descr && 'set' in descr;
}();

function installProperty(source, target, allowMethod, opt_blacklist) {
var names = getOwnPropertyNames(source);
for (var i = 0; i < names.length; i++) {
Expand Down Expand Up @@ -204,7 +213,7 @@ window.ShadowDOMPolyfill = {};
else
getter = getGetter(name);

if (descriptor.writable || descriptor.set) {
if (descriptor.writable || descriptor.set || isBrokenSafari) {
if (isEvent)
setter = scope.getEventHandlerSetter(name);
else
Expand Down

0 comments on commit cfaa850

Please sign in to comment.