mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Fix URL attributes
URL attributes should always use AttrValue::Url, and the input should be resolved against the document's base URL at setting time always.
This commit is contained in:
parent
826352ab4c
commit
605c679fee
11 changed files with 75 additions and 47 deletions
|
@ -42,6 +42,7 @@ use std::io::{Read, Write};
|
|||
use std::path::PathBuf;
|
||||
use std::process::{Command, Stdio};
|
||||
use std::sync::{Arc, Mutex};
|
||||
use style::attr::AttrValue;
|
||||
use style::str::{HTML_SPACE_CHARACTERS, StaticStringVec};
|
||||
use uuid::Uuid;
|
||||
|
||||
|
@ -653,6 +654,13 @@ impl VirtualMethods for HTMLScriptElement {
|
|||
Some(self.upcast::<HTMLElement>() as &VirtualMethods)
|
||||
}
|
||||
|
||||
fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue {
|
||||
match name {
|
||||
&local_name!("src") => AttrValue::from_url(document_from_node(self).base_url(), value.into()),
|
||||
_ => self.super_type().unwrap().parse_plain_attribute(name, value),
|
||||
}
|
||||
}
|
||||
|
||||
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
|
||||
self.super_type().unwrap().attribute_mutated(attr, mutation);
|
||||
match *attr.local_name() {
|
||||
|
@ -702,8 +710,9 @@ impl VirtualMethods for HTMLScriptElement {
|
|||
impl HTMLScriptElementMethods for HTMLScriptElement {
|
||||
// https://html.spec.whatwg.org/multipage/#dom-script-src
|
||||
make_url_getter!(Src, "src");
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-script-src
|
||||
make_setter!(SetSrc, "src");
|
||||
make_url_setter!(SetSrc, "src");
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-script-type
|
||||
make_getter!(Type, "type");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue