Reputation: 51
Here is a basic hello world web component. The attributeChangedCallback does not get triggered when the attribute "who" is changed. Check the fiddle
MyElementProto.attributeChangedCallback = function(attr, oldVal, newVal) {
console.log('attributeChangedCallback triggered');
if (attr === 'who') {
this.setWho(newVal);
}
};
https://jsfiddle.net/y3kj81nz/5/
Upvotes: 1
Views: 1594
Reputation: 17064
You need to use the setAttribute
method:
window.changeWhoAttr = function() {
var el = document.querySelector('#custom-tag');
el.setAttribute('who', 'Universe'); // Instead of el.who = 'Universe'
console.log('changeWhoAttr triggered');
}
Upvotes: 5