Calling DOM Element.attributes shouldn't force creation of ElementData.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 16 Feb 2013 01:39:19 +0000 (01:39 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 16 Feb 2013 01:39:19 +0000 (01:39 +0000)
commitcb72c060bba23ae616d346c18447d2a6c26ab16f
tree8fabbc98c04a312e134b415285e9e158e65484a0
parente50cd74258b2adac0384caacc999e855ab086448
Calling DOM Element.attributes shouldn't force creation of ElementData.
<http://webkit.org/b/109976>

Reviewed by Darin Adler.

Don't create ElementData for an Element unnecessarily just because someone calls .attributes on it.
Previously, JS like this would create empty ElementData when 'element' has no attributes:

    for (i = 0; i < element.attributes.length; ++i)
        doStuff(element.attributes[i]);

Make NamedNodeMap::length() short-circuit and return 0 if !Element::hasAttributes().

* dom/Element.cpp:
(WebCore::Element::attributes):
* dom/NamedNodeMap.cpp:
(WebCore::NamedNodeMap::length):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@143076 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/NamedNodeMap.cpp