Fixed value change observers not firing#697
Conversation
Fixed value change observers not firing when the controller name contains upper case characters.
|
I haven't found documentation about this, but it looks like the mutation observer reports property names always in lowercase (and since HTML is supposed to be case insensitive, I think it's fair). For this reason, my fix is to also track the properties that stimulus cares about in lowercase. I'm not sure the spot I touched is the right one, but at least no other test breaks. |
|
|
||
| getAttributeNameForKey(key: string): string { | ||
| return `data-${this.identifier}-${dasherize(key)}` | ||
| return `data-${this.identifier.toLowerCase()}-${dasherize(key)}` |
There was a problem hiding this comment.
I'm not sure if this is the right fix for the issue raised in #680. The attribute methods on Element seem to be case-insensitive, which leads me to believe that we need to week this somewhere else.
There was a problem hiding this comment.
If I get what you mean, they are case insensitive, meaning that you can read or write them with whatever casing and it would still work, but the mutation observer always reports the changed properties as lowercase strings. The consequence is that when we check if we should care about the property change, we always opt to discard the change event, because we instead stored the property with whatever casing was found in the document. I've not found this documented anywhere, but I tried both Chromium and Firefox and both did the same.
If I didn't get what you mean, could you point me in the direction where you think the fix should be made instead?
There was a problem hiding this comment.
Hey @RBastianini, I just realized that my comment wasn't very well thought out, sorry about that! Let me dig into this and come back with a more constructive answer. Thank you!
Fixed value change observers not firing when the controller name
contains upper case characters.
Fixes #680.