Index: Source/core/dom/Node.cpp |
diff --git a/Source/core/dom/Node.cpp b/Source/core/dom/Node.cpp |
index d413a591b5b1828239c0d50fcc274f9b5ba56794..715cedf7c0813486da9fcb8af0a7f767c7bb8aa6 100644 |
--- a/Source/core/dom/Node.cpp |
+++ b/Source/core/dom/Node.cpp |
@@ -1698,20 +1698,23 @@ String Node::debugName() const |
StringBuilder name; |
name.append(nodeName()); |
- if (hasID()) { |
- name.appendLiteral(" id=\'"); |
- name.append(toElement(this)->getIdAttribute()); |
- name.append('\''); |
- } |
- |
- if (hasClass()) { |
- name.appendLiteral(" class=\'"); |
- for (size_t i = 0; i < toElement(this)->classNames().size(); ++i) { |
- if (i > 0) |
- name.append(' '); |
- name.append(toElement(this)->classNames()[i]); |
+ if (isElementNode()) { |
+ const Element& thisElement = toElement(*this); |
+ if (thisElement.hasID()) { |
+ name.appendLiteral(" id=\'"); |
+ name.append(thisElement.getIdAttribute()); |
+ name.append('\''); |
+ } |
+ |
+ if (thisElement.hasClass()) { |
+ name.appendLiteral(" class=\'"); |
+ for (size_t i = 0; i < thisElement.classNames().size(); ++i) { |
+ if (i > 0) |
+ name.append(' '); |
+ name.append(thisElement.classNames()[i]); |
+ } |
+ name.append('\''); |
} |
- name.append('\''); |
} |
return name.toString(); |