Handle null strings in Namespace::new.

This also avoids a string copy in the rare case of an unrecognized namespace.
This commit is contained in:
Ms2ger 2014-09-23 22:22:45 +02:00
parent 4546d5d23c
commit d3d7c1dabd
5 changed files with 21 additions and 24 deletions

View file

@ -57,7 +57,7 @@ use layout_interface::{DocumentDamageLevel, ContentChangedDocumentDamage};
use servo_util::atom::Atom;
use servo_util::namespace;
use servo_util::namespace::{Namespace, Null};
use servo_util::str::{DOMString, null_str_as_empty_ref, split_html_space_chars};
use servo_util::str::{DOMString, split_html_space_chars};
use std::collections::hashmap::HashMap;
use std::ascii::StrAsciiExt;
@ -464,7 +464,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
fn CreateElementNS(self,
namespace: Option<DOMString>,
qualified_name: DOMString) -> Fallible<Temporary<Element>> {
let ns = Namespace::from_str(null_str_as_empty_ref(&namespace));
let ns = Namespace::from_str(namespace);
match xml_name_type(qualified_name.as_slice()) {
InvalidXMLName => {
debug!("Not a valid element name");