mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Merge pull request #61 from spicyj/getdomnodeid
getDOMNodeID: Don't return .id on random objects
This commit is contained in:
@@ -21,8 +21,9 @@
|
||||
|
||||
/**
|
||||
* Accessing "id" or calling getAttribute('id') on a form element can return its
|
||||
* control whose name or ID is "id". However, not all DOM nodes support
|
||||
* `getAttributeNode` (document - which is not a form) so that is checked first.
|
||||
* control whose name or ID is "id". All DOM nodes support `getAttributeNode`
|
||||
* but this can also get called on other objects so just return '' if we're
|
||||
* given something other than a DOM node (such as window).
|
||||
*
|
||||
* @param {DOMElement|DOMWindow|DOMDocument} domNode DOM node.
|
||||
* @returns {string} ID of the supplied `domNode`.
|
||||
@@ -32,7 +33,7 @@ function getDOMNodeID(domNode) {
|
||||
var attributeNode = domNode.getAttributeNode('id');
|
||||
return attributeNode && attributeNode.value || '';
|
||||
} else {
|
||||
return domNode.id || '';
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user