diff options
author | Keith Yeung <kungfukeith11@gmail.com> | 2015-03-19 16:25:09 +0800 |
---|---|---|
committer | Ms2ger <ms2ger@gmail.com> | 2015-04-01 12:43:17 +0200 |
commit | fdcf9618cbf853920c14045fc8e76a3564416994 (patch) | |
tree | 432ec7a517d4f7b8f0ff1ecd84ca43f868e0902d /components/script/dom/htmlscriptelement.rs | |
parent | 4846607e189a65baf8d9ac6566594b7893d07f12 (diff) | |
download | servo-fdcf9618cbf853920c14045fc8e76a3564416994.tar.gz servo-fdcf9618cbf853920c14045fc8e76a3564416994.zip |
Handle the for and event attributes on a script element correctly when one of them is present (fixes #5258).
Diffstat (limited to 'components/script/dom/htmlscriptelement.rs')
-rw-r--r-- | components/script/dom/htmlscriptelement.rs | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/components/script/dom/htmlscriptelement.rs b/components/script/dom/htmlscriptelement.rs index 637cb23ee2f..8dca04ec736 100644 --- a/components/script/dom/htmlscriptelement.rs +++ b/components/script/dom/htmlscriptelement.rs @@ -202,25 +202,26 @@ impl<'a> HTMLScriptElementHelpers for JSRef<'a, HTMLScriptElement> { } // Step 12. - match element.get_attribute(ns!(""), &atom!("for")).root() { - Some(for_script) => { - if for_script.r().Value().to_ascii_lowercase().trim_matches(HTML_SPACE_CHARACTERS) != "window" { + let for_attribute = element.get_attribute(ns!(""), &atom!("for")).root(); + let event_attribute = element.get_attribute(ns!(""), &Atom::from_slice("event")).root(); + match (for_attribute.r(), event_attribute.r()) { + (Some(for_attribute), Some(event_attribute)) => { + let for_value = for_attribute.Value() + .to_ascii_lowercase(); + let for_value = for_value.trim_matches(HTML_SPACE_CHARACTERS); + if for_value != "window" { return; } - } - _ => { } - } - match element.get_attribute(ns!(""), &Atom::from_slice("event")).root() { - Some(event) => { - let event = event.r().Value().to_ascii_lowercase(); - let event = event.trim_matches(HTML_SPACE_CHARACTERS); - if event != "onload" && event != "onload()" { + let event_value = event_attribute.Value().to_ascii_lowercase(); + let event_value = event_value.trim_matches(HTML_SPACE_CHARACTERS); + if event_value != "onload" && event_value != "onload()" { return; } - } - _ => { } + }, + (_, _) => (), } + // Step 13. if let Some(charset) = element.get_attribute(ns!(""), &Atom::from_slice("charset")).root() { if let Some(encodingRef) = encoding_from_whatwg_label(&charset.r().Value()) { |