Bug 129316 - Setting `element.id = null` should not remove the `id` attribute
Summary: Setting `element.id = null` should not remove the `id` attribute
Status: RESOLVED CONFIGURATION CHANGED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL: data:text/html,<p%20id=x></p><script>...
Keywords:
Depends on:
Blocks:
 
Reported: 2014-02-25 10:07 PST by Mathias Bynens
Modified: 2022-08-09 15:36 PDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mathias Bynens 2014-02-25 10:07:07 PST
Setting `element.id = null` should have the same result as `element.id = 'null'`. In Safari, this remove the `id` attribute instead.

Test case:

data:text/html,<p%20id=x></p><script>var%20el%20=%20x;%20el.id%20=%20null;%20document.write(el.id%20===%20'null'%20?%20'PASS'%20:%20'FAIL')</script>

Chrome, Opera, and Firefox get it right.
Comment 1 Ahmad Saleem 2022-08-09 15:36:26 PDT
I took the test case from Comment 0 and replaced %20 with Space and then changed it into JSFiddle:

Link - https://jsfiddle.net/cwdjomup/

It shows "PASS" for all browsers (Chrome Canary 106, Firefox Nightly 105 and Safari 15.6 on macOS 12.5). I think something along the line fixed it. So I am marking this as "RESOLVED CONFIGURATION CHANGED". Thanks!