Summary: | Using document.appendChild to create a new element with ID attribute creates a property / global variable on window | ||||||
---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Fabio Kenji <seibzhen> | ||||
Component: | DOM | Assignee: | Nobody <webkit-unassigned> | ||||
Status: | RESOLVED INVALID | ||||||
Severity: | Normal | ||||||
Priority: | P2 | ||||||
Version: | 528+ (Nightly build) | ||||||
Hardware: | Mac | ||||||
OS: | OS X 10.10 | ||||||
Attachments: |
|
Nevermind - my mistake, did not not know each element in the page with an ID is accessible through window. |
Created attachment 241682 [details] a web page with the steps used on the bug report It seems that when using the DOM API to create new nodes on a webpage and specifying an ID attribute, a global variable / property on window object is created with the same name as the specified ID. In the example attached, I am getting a reference to a paragraph in the body of the page. After that, I am creating a new div node and setting its id attribute to 'test_variable'. In the next lines, I am appending it into the paragraph node reference I had gotten earlier using appendChild(). After that code is run, a new property on window is created, window.test_variable, having the reference to a HTMLDivElementConstructor.