Only process properties that have actually changed

master
Sven Slootweg 7 years ago
parent f44f95fbf2
commit e0a8385eb0

@ -36,6 +36,14 @@ module.exports = function createObject(options) {
transformedProperties = properties;
}
Object.keys(transformedProperties).forEach((property) => {
/* Don't apply unchanged properties, to prevent unnecessary cache or size busting. */
if (this[property] === transformedProperties[property]) {
delete transformedProperties[property];
}
});
if (Object.keys(transformedProperties).length > 0) {
Object.assign(this, transformedProperties);
if (Object.keys(transformedProperties).some(property => this.sizeBustingProperties.includes(property))) {
@ -45,6 +53,7 @@ module.exports = function createObject(options) {
} else if (Object.keys(transformedProperties).some(property => this.cacheBustingProperties.includes(property))) {
this.bustCache();
}
}
},
render: function renderObject(context, options = {}) {
if (this.isCached === false) {

Loading…
Cancel
Save