proper html id attribute semantics

#WEB-369 fixed
This commit is contained in:
Dennis Ushakov
2014-09-06 13:32:17 +04:00
parent cd3bd59dfe
commit 2200591949
@@ -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;
}
});