Skip to content

Commit

Permalink
Make type argument as optional and ignore it in open method
Browse files Browse the repository at this point in the history
  • Loading branch information
CYBAI committed Mar 20, 2018
1 parent 8028ee3 commit 65da9b5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
20 changes: 4 additions & 16 deletions components/script/dom/document.rs
Expand Up @@ -132,7 +132,7 @@ use style::invalidation::element::restyle_hints::RestyleHint;
use style::media_queries::{Device, MediaList, MediaType};
use style::selector_parser::{RestyleDamage, Snapshot};
use style::shared_lock::{SharedRwLock as StyleSharedRwLock, SharedRwLockReadGuard};
use style::str::{HTML_SPACE_CHARACTERS, split_html_space_chars, str_join};
use style::str::{split_html_space_chars, str_join};
use style::stylesheet_set::DocumentStylesheetSet;
use style::stylesheets::{Stylesheet, StylesheetContents, Origin, OriginSet};
use task_source::TaskSource;
Expand Down Expand Up @@ -3675,7 +3675,7 @@ impl DocumentMethods for Document {
}

// https://html.spec.whatwg.org/multipage/#dom-document-open
fn Open(&self, type_: DOMString, replace: DOMString) -> Fallible<DomRoot<Document>> {
fn Open(&self, _type: Option<DOMString>, replace: DOMString) -> Fallible<DomRoot<Document>> {
if !self.is_html_document() {
// Step 1.
return Err(Error::InvalidState);
Expand Down Expand Up @@ -3709,8 +3709,6 @@ impl DocumentMethods for Document {
// Step 6.
// TODO: ignore-opens-during-unload counter check.

// Step 7: first argument already bound to `type_`.

// Step 8.
// TODO: check session history's state.
let replace = replace.eq_ignore_ascii_case("replace");
Expand Down Expand Up @@ -3777,22 +3775,12 @@ impl DocumentMethods for Document {
// Step 24.
// TODO: mute iframe load.

// Step 27.
let type_ = if type_.eq_ignore_ascii_case("replace") {
"text/html"
} else if let Some(position) = type_.find(';') {
&type_[0..position]
} else {
&*type_
};
let type_ = type_.trim_matches(HTML_SPACE_CHARACTERS);

// Step 25.
let resource_threads =
self.window.upcast::<GlobalScope>().resource_threads().clone();
*self.loader.borrow_mut() =
DocumentLoader::new_with_threads(resource_threads, Some(url.clone()));
ServoParser::parse_html_script_input(self, url, type_);
ServoParser::parse_html_script_input(self, url, "text/html");

// Step 26.
self.ready_state.set(DocumentReadyState::Interactive);
Expand Down Expand Up @@ -3851,7 +3839,7 @@ impl DocumentMethods for Document {
return Ok(());
}
// Step 5.
self.Open("text/html".into(), "".into())?;
self.Open(None, "".into())?;
self.get_current_parser().unwrap()
}
};
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/webidls/Document.webidl
Expand Up @@ -118,7 +118,7 @@ partial /*sealed*/ interface Document {

// dynamic markup insertion
[CEReactions, Throws]
Document open(optional DOMString type = "text/html", optional DOMString replace = "");
Document open(optional DOMString type, optional DOMString replace = "");
// WindowProxy open(DOMString url, DOMString name, DOMString features, optional boolean replace = false);
[CEReactions, Throws]
void close();
Expand Down

0 comments on commit 65da9b5

Please sign in to comment.