Bug 148780

Summary: DOMTokenList.add() / remove() should run the update steps even if tokens were not modified
Product: WebKit Reporter: Ryosuke Niwa <rniwa>
Component: DOMAssignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: benjamin, cdumez, commit-queue, darin, esprehn+autocc, gyuyoung.kim, rniwa, sam, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=148589
Attachments:
Description Flags
Patch
none
Patch none

Description Ryosuke Niwa 2015-09-03 20:07:47 PDT
MutationObserver should be getting new records on classList.add/remove even if they're no-op.

See https://dom.spec.whatwg.org/#concept-DTL-update

Firefox adds the records as expected by the spec.

This bug was found by the newly added test: LayoutTests/http/tests/w3c/dom/nodes/MutationObserver-attributes.html
Comment 1 Radar WebKit Bug Importer 2015-09-03 20:08:06 PDT
<rdar://problem/22571794>
Comment 2 Chris Dumez 2015-09-21 11:51:55 PDT
Created attachment 261670 [details]
Patch
Comment 3 Ryosuke Niwa 2015-09-21 12:00:58 PDT
Comment on attachment 261670 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=261670&action=review

> LayoutTests/fast/dom/rel-list.html:80
>      element.relList.add('x');
> -    shouldBeEqualToString('element.rel', 'x  x');
> +    shouldBeEqualToString('element.rel', 'x');

This seems like an orthogonal behavioral change.
This is expected?  If so, we should explain why this behavior change is desirable in the change log.
Comment 4 Chris Dumez 2015-09-21 13:02:57 PDT
Comment on attachment 261670 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=261670&action=review

>> LayoutTests/fast/dom/rel-list.html:80
>> +    shouldBeEqualToString('element.rel', 'x');
> 
> This seems like an orthogonal behavioral change.
> This is expected?  If so, we should explain why this behavior change is desirable in the change log.

Not really an orthogonal change, as per the specification, we can the update steps even if the token update is a no-op. The update steps are:
https://dom.spec.whatwg.org/#concept-DTL-update

Step 2 is "Set an attribute value for the associated element using associated attribute’s local name and the result of running the ordered set serializer for tokens." Setting the attribute value will generate a mutation event but will also possible change the value as "ordered set serializer for tokens" will clean up the attribute value. I will update the change log to clarify before landing.
Comment 5 Chris Dumez 2015-09-21 13:09:45 PDT
Created attachment 261680 [details]
Patch
Comment 6 WebKit Commit Bot 2015-09-21 13:59:31 PDT
Comment on attachment 261680 [details]
Patch

Clearing flags on attachment: 261680

Committed r190078: <http://trac.webkit.org/changeset/190078>
Comment 7 WebKit Commit Bot 2015-09-21 13:59:37 PDT
All reviewed patches have been landed.  Closing bug.