Bug 148780 - DOMTokenList.add() / remove() should run the update steps even if tokens were not modified
Summary: DOMTokenList.add() / remove() should run the update steps even if tokens were...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2015-09-03 20:07 PDT by Ryosuke Niwa
Modified: 2015-09-21 13:59 PDT (History)
9 users (show)

See Also:


Attachments
Patch (9.24 KB, patch)
2015-09-21 11:51 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (9.83 KB, patch)
2015-09-21 13:09 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.