Skip to content

Commit

Permalink
Merge pull request #5170 from Polymer/attribute-changed-namespace
Browse files Browse the repository at this point in the history
Pass through fourth namespace param on attributeChangedCallback.
  • Loading branch information
rictic authored Mar 31, 2018
2 parents b9dcf51 + 5357d64 commit 55d9175
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 15 deletions.
8 changes: 5 additions & 3 deletions externs/closure-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,10 @@ Polymer_PropertiesChanged.prototype._shouldPropertyChange = function(property, v
* @param {string} name Name of attribute that changed
* @param {?string} old Old attribute value
* @param {?string} value New attribute value
* @param {?string} namespace Attribute namespace.
* @return {void}
*/
Polymer_PropertiesChanged.prototype.attributeChangedCallback = function(name, old, value){};
Polymer_PropertiesChanged.prototype.attributeChangedCallback = function(name, old, value, namespace){};
/**
* @param {string} attribute Name of attribute to deserialize.
* @param {?string} value of the attribute.
Expand Down Expand Up @@ -972,9 +973,10 @@ Polymer_LegacyElementMixin.prototype._initializeProperties = function(){};
* @param {string} name Name of attribute.
* @param {?string} old Old value of attribute.
* @param {?string} value Current value of attribute.
* @param {?string} namespace Attribute namespace.
* @return {void}
*/
Polymer_LegacyElementMixin.prototype.attributeChangedCallback = function(name, old, value){};
Polymer_LegacyElementMixin.prototype.attributeChangedCallback = function(name, old, value, namespace){};
/**
* @override
* @return {void}
Expand Down Expand Up @@ -1391,7 +1393,7 @@ Polymer_DisableUpgradeMixin.prototype._enableProperties = function(){};
/**
* @override
*/
Polymer_DisableUpgradeMixin.prototype.attributeChangedCallback = function(name, old, value){};
Polymer_DisableUpgradeMixin.prototype.attributeChangedCallback = function(name, old, value, namespace){};
/**
* @override
*/
Expand Down
5 changes: 4 additions & 1 deletion lib/elements/dom-module.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,20 @@
return null;
}

/* eslint-disable no-unused-vars */
/**
* @param {string} name Name of attribute.
* @param {?string} old Old value of attribute.
* @param {?string} value Current value of attribute.
* @param {?string} namespace Attribute namespace.
* @return {void}
*/
attributeChangedCallback(name, old, value) {
attributeChangedCallback(name, old, value, namespace) {
if (old !== value) {
this.register();
}
}
/* eslint-enable no-unused-args */

/**
* The absolute URL of the original location of this `dom-module`.
Expand Down
5 changes: 3 additions & 2 deletions lib/legacy/legacy-element-mixin.html
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,13 @@
* @param {string} name Name of attribute.
* @param {?string} old Old value of attribute.
* @param {?string} value Current value of attribute.
* @param {?string} namespace Attribute namespace.
* @return {void}
* @override
*/
attributeChangedCallback(name, old, value) {
attributeChangedCallback(name, old, value, namespace) {
if (old !== value) {
super.attributeChangedCallback(name, old, value);
super.attributeChangedCallback(name, old, value, namespace);
this.attributeChanged(name, old, value);
}
}
Expand Down
6 changes: 3 additions & 3 deletions lib/mixins/disable-upgrade-mixin.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@
}

/** @override */
attributeChangedCallback(name, old, value) {
attributeChangedCallback(name, old, value, namespace) {
if (name == DISABLED_ATTR) {
if (!this.__dataEnabled && value == null && this.isConnected) {
super.connectedCallback();
}
} else {
super.attributeChangedCallback(name, old, value);
super.attributeChangedCallback(name, old, value, namespace);
}
}

Expand Down Expand Up @@ -113,4 +113,4 @@

})();

</script>
</script>
5 changes: 3 additions & 2 deletions lib/mixins/properties-changed.html
Original file line number Diff line number Diff line change
Expand Up @@ -407,15 +407,16 @@
* @param {string} name Name of attribute that changed
* @param {?string} old Old attribute value
* @param {?string} value New attribute value
* @param {?string} namespace Attribute namespace.
* @return {void}
* @suppress {missingProperties} Super may or may not implement the callback
*/
attributeChangedCallback(name, old, value) {
attributeChangedCallback(name, old, value, namespace) {
if (old !== value) {
this._attributeToProperty(name, value);
}
if (super.attributeChangedCallback) {
super.attributeChangedCallback(name, old, value);
super.attributeChangedCallback(name, old, value, namespace);
}
}

Expand Down
2 changes: 2 additions & 0 deletions test/smoke/behavior-mixin.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
</template>
</dom-module>
<script>
/** @polymerBehavior */
var MyBehavior = {
properties: {
behaviorProp: {
Expand All @@ -37,6 +38,7 @@
}
}

/** @polymerBehavior */
var MyBehavior2 = {
ready: function() {
console.log(this.localName, 'MyBehavior2.ready');
Expand Down
3 changes: 2 additions & 1 deletion types/lib/elements/dom-module.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ declare namespace Polymer {
* @param name Name of attribute.
* @param old Old value of attribute.
* @param value Current value of attribute.
* @param namespace Attribute namespace.
*/
attributeChangedCallback(name: string, old: string|null, value: string|null): void;
attributeChangedCallback(name: string, old: string|null, value: string|null, namespace: string|null): void;

/**
* Registers the dom-module at a given id. This method should only be called
Expand Down
3 changes: 2 additions & 1 deletion types/lib/legacy/legacy-element-mixin.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ declare namespace Polymer {
* @param name Name of attribute.
* @param old Old value of attribute.
* @param value Current value of attribute.
* @param namespace Attribute namespace.
*/
attributeChangedCallback(name: string, old: string|null, value: string|null): void;
attributeChangedCallback(name: string, old: string|null, value: string|null, namespace: string|null): void;

/**
* Provides an implementation of `connectedCallback`
Expand Down
2 changes: 1 addition & 1 deletion types/lib/mixins/disable-upgrade-mixin.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ declare namespace Polymer {
interface DisableUpgradeMixin {
_initializeProperties(): void;
_enableProperties(): void;
attributeChangedCallback(name: any, old: any, value: any): void;
attributeChangedCallback(name: any, old: any, value: any, namespace: any): void;
connectedCallback(): void;
disconnectedCallback(): void;
}
Expand Down
3 changes: 2 additions & 1 deletion types/lib/mixins/properties-changed.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,9 @@ declare namespace Polymer {
* @param name Name of attribute that changed
* @param old Old attribute value
* @param value New attribute value
* @param namespace Attribute namespace.
*/
attributeChangedCallback(name: string, old: string|null, value: string|null): void;
attributeChangedCallback(name: string, old: string|null, value: string|null, namespace: string|null): void;

/**
* Deserializes an attribute to its associated property.
Expand Down

0 comments on commit 55d9175

Please sign in to comment.