summaryrefslogtreecommitdiff
path: root/xml/xml-analysis-impl/src/com/intellij/xml/util/XmlRefCountHolder.java
diff options
context:
space:
mode:
Diffstat (limited to 'xml/xml-analysis-impl/src/com/intellij/xml/util/XmlRefCountHolder.java')
-rw-r--r--xml/xml-analysis-impl/src/com/intellij/xml/util/XmlRefCountHolder.java14
1 files changed, 14 insertions, 0 deletions
diff --git a/xml/xml-analysis-impl/src/com/intellij/xml/util/XmlRefCountHolder.java b/xml/xml-analysis-impl/src/com/intellij/xml/util/XmlRefCountHolder.java
index a5f70c2227dc..a9f91bce7d8b 100644
--- a/xml/xml-analysis-impl/src/com/intellij/xml/util/XmlRefCountHolder.java
+++ b/xml/xml-analysis-impl/src/com/intellij/xml/util/XmlRefCountHolder.java
@@ -105,10 +105,24 @@ public class XmlRefCountHolder {
myId2AttributeListMap.put(id, list);
}
else if (!soft) {
+ final boolean html = HtmlUtil.isHtmlFile(attributeValue);
+ final boolean html5 = HtmlUtil.isHtml5Context(attributeValue);
+
// mark as duplicate
List<XmlAttributeValue> notSoft = ContainerUtil.mapNotNull(list, new NullableFunction<Pair<XmlAttributeValue, Boolean>, XmlAttributeValue>() {
@Override
public XmlAttributeValue fun(Pair<XmlAttributeValue, Boolean> pair) {
+ if (html5 && !"id".equalsIgnoreCase(((XmlAttribute)pair.first.getParent()).getName())) {
+ // according to HTML 5 (http://www.w3.org/TR/html5/dom.html#the-id-attribute) spec
+ // only id attribute is unique identifier
+ return null;
+ }
+ if (html && pair.first.getParent().getParent() == attributeValue.getParent().getParent()) {
+ // according to HTML 4 (http://www.w3.org/TR/html401/struct/global.html#adef-id,
+ // http://www.w3.org/TR/html401/struct/links.html#h-12.2.3) spec id and name occupy
+ // same namespace, but having same values on one tag is ok
+ return null;
+ }
return pair.second ? null : pair.first;
}
});