Open
Bug 1449489
Opened 7 years ago
Updated 2 years ago
Edit attributes in inspector dev tool does not trigger attributeChangedCallback
Categories
(DevTools :: Inspector, defect, P3)
Tracking
(Not tracked)
NEW
People
(Reporter: andy.782542, Unassigned)
Details
Attachments
(1 file)
9.23 MB,
image/gif
|
Details |
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36
Steps to reproduce:
I created a Custom Element V1, polyfilled it by official polyfill from https://www.webcomponents.org/polyfills.
Then I set the oberservedAttributes static array. The attributeChangedCallback only triggers if I use real JS code like setAttribute('foo', 'bar').
Then I went to https://axa-ch.github.io/patterns-library/
But if I change the <axa-icon icon="logo-AXA"> icon-attribute within the inspector dev-tool to facebook, nothing happens.
Actual results:
Nothing.
Expected results:
attributeChangedCallback should have been triggered, since I changed the attribute's value through inspector devtool and as a result the new icon should be displayed.
Comment 1•7 years ago
|
||
I expect this to be by design, but sending over to dev tools to be sure.
Component: DOM: Core & HTML → Developer Tools: Inspector
Product: Core → Firefox
Updated•7 years ago
|
Product: Firefox → DevTools
Comment 2•7 years ago
|
||
DevTools does exactly the same thing as you did with JS code. See https://searchfox.org/mozilla-central/rev/39b790b29543a4718d876d8ca3fd179d82fc24f7/devtools/server/actors/inspector/node.js#636-653
In particular this line:
rawNode.setAttribute(change.attributeName, change.newValue);
So, the fact that DevTools runs in a privileged way must be making the difference here.
I just checked and Google Chrome does call the callback when the attribute is changed from the inspector.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Priority: -- → P3
The behavior I see now is: works well with setAttribute()
, but if changing an attribute value in inspector, it'll change the attribute value from old value to null
first, then null
to new value. The code I used to test is as following:
customElements.define('my-el', class extends HTMLElement {
static get observedAttributes() {
return ['foo'];
}
constructor() {
super();
}
attributeChangedCallback(name, oldVal, newVal) {
console.log({name, oldVal, newVal});
}
});
<my-el foo="bar"></my-el>
When editing foo
's value to baz
, you can see 2 log entries printed out:
{name: "foo", oldVal: "bar", newVal: null}
{name: "foo", oldVal: null, newVal: "baz"}
Updated•2 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•