Chromium Code Reviews

Unified Diff: Source/core/dom/Document.cpp

Issue 243333003: Add back three deprecated DOM APIs removed from Chrome 34 (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Index: Source/core/dom/Document.cpp
diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp
index 8c770732ac76657342f57532da35367f200f9e9a..43e7d00eda7ca34bfb28f3657c8b644e2c9260bd 100644
--- a/Source/core/dom/Document.cpp
+++ b/Source/core/dom/Document.cpp
@@ -4427,11 +4427,21 @@ WeakPtr<Document> Document::contextDocument()
PassRefPtr<Attr> Document::createAttribute(const AtomicString& name, ExceptionState& exceptionState)
{
+ return createAttributeNS(nullAtom, name, exceptionState, true);
+}
+
+PassRefPtr<Attr> Document::createAttributeNS(const AtomicString& namespaceURI, const AtomicString& qualifiedName, ExceptionState& exceptionState, bool shouldIgnoreNamespaceChecks)
+{
AtomicString prefix, localName;
- if (!parseQualifiedName(name, prefix, localName, exceptionState))
+ if (!parseQualifiedName(qualifiedName, prefix, localName, exceptionState))
return nullptr;
- QualifiedName qName(prefix, localName, nullAtom);
+ QualifiedName qName(prefix, localName, namespaceURI);
+
+ if (!shouldIgnoreNamespaceChecks && !hasValidNamespaceForAttributes(qName)) {
+ exceptionState.throwDOMException(NamespaceError, "The namespace URI provided ('" + namespaceURI + "') is not valid for the qualified name provided ('" + qualifiedName + "').");
+ return nullptr;
+ }
return Attr::create(*this, qName, emptyAtom);
}

Powered by Google App Engine