Skip to content

Commit

Permalink
Merge branch 'object-assign-ie11'
Browse files Browse the repository at this point in the history
  • Loading branch information
bicknellr committed Jun 15, 2018
2 parents a72ca2a + cf12317 commit ca507a3
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions app-localize-behavior.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@
<script src="../intl-messageformat/dist/intl-messageformat.min.js"></script>

<script>
(function() {

// This isn't a complete `Object.assign` polyfill, but this element expects
// JSON and doesn't provide more than one source object.
var assign = Object.assign ? Object.assign.bind(Object) : function(destination, source) {
for (var prop in source) {
if (source.hasOwnProperty(prop)) {
destination[prop] = source[prop];
}
}

return destination;
};

/**
* `Polymer.AppLocalizeBehavior` wraps the [format.js](http://formatjs.io/) library to
Expand Down Expand Up @@ -292,11 +305,11 @@
var newResources = event.response;
if (merge) {
if (language) {
propertyUpdates.resources = Object.assign({}, this.resources || {});
propertyUpdates['resources.' + language] = Object.assign(
propertyUpdates.resources = assign({}, this.resources || {});
propertyUpdates['resources.' + language] = assign(
propertyUpdates.resources[language] || {}, newResources);
} else {
propertyUpdates.resources = Object.assign(this.resources, newResources);
propertyUpdates.resources = assign(this.resources, newResources);
}
} else {
if (language) {
Expand Down Expand Up @@ -330,6 +343,7 @@
proto['__localizationCache'] = {requests: {}, messages: {}, ajax: null};
}
}
}
};

})();
</script>

0 comments on commit ca507a3

Please sign in to comment.