RESOLVED FIXED Bug 53752
[JSC binding] Inconsistent behavior of DOMStringMap
https://bugs.webkit.org/show_bug.cgi?id=53752
Summary [JSC binding] Inconsistent behavior of DOMStringMap
Kent Tamura
Reported 2011-02-03 20:33:31 PST
The behavior of the current JSC binding for DOMStringMap is: put: Handle JavaScript property first, then handle HTML attribute if there is not JS property. delete: ditto. get: Handle HTML attribute, then handle JavaScript property. The get operation is inconsistent with put/delete. So, we have the following curious behavior: 1> document.body.dataset.toString function toString() { ... 2> document.body.setAttribute('data-to-string', 'attr') 3> document.body.dataset.toString "attr" 4> document.body.dataset.toString = function() { return "dataset"; } 5> document.body.dataset.toString "attr" Even if one sets a new value to .toString [4], .toString doesn't return the new value [5]. It's not good. I think it's reasonable to handle JavaScript properties first to protect JavaScript Object behavior. However, we should do it in the get operation too and should give up providing "data-to-string" attribute via HTMLElement::dataset for consistency.
Attachments
Incomplete patch (3.98 KB, patch)
2011-02-06 18:20 PST, Kent Tamura
no flags
Patch (9.22 KB, patch)
2011-10-06 01:59 PDT, Kent Tamura
no flags
Kent Tamura
Comment 1 2011-02-06 18:20:07 PST
Created attachment 81440 [details] Incomplete patch The last test (delete div.dataset.foobarbaz) doesn't work.
Kent Tamura
Comment 2 2011-10-06 01:39:05 PDT
(In reply to comment #0) > I think it's reasonable to handle JavaScript properties first to protect JavaScript Object behavior. However, we should do it in the get operation too and should give up providing "data-to-string" attribute via HTMLElement::dataset for consistency. I changed my mind. Both of Firefox and Opera always handles data-* attributes first. We had better follow them.
Kent Tamura
Comment 3 2011-10-06 01:59:48 PDT
Darin Adler
Comment 4 2011-10-06 14:01:55 PDT
Comment on attachment 109933 [details] Patch Looks good.
Kent Tamura
Comment 5 2011-10-06 15:58:31 PDT
Comment on attachment 109933 [details] Patch Thank you for reviewing.
WebKit Review Bot
Comment 6 2011-10-06 19:43:59 PDT
Comment on attachment 109933 [details] Patch Clearing flags on attachment: 109933 Committed r96893: <http://trac.webkit.org/changeset/96893>
WebKit Review Bot
Comment 7 2011-10-06 19:44:04 PDT
All reviewed patches have been landed. Closing bug.
Kent Tamura
Comment 8 2011-10-07 00:05:44 PDT
Note You need to log in before you can comment on or make changes to this bug.