Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the correct IDL setter for <font>.size #7898

Merged
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -70,7 +70,11 @@ impl HTMLFontElementMethods for HTMLFontElement {
make_getter!(Size);

// https://html.spec.whatwg.org/multipage/#dom-font-size
make_setter!(SetSize, "size");
fn SetSize(&self, value: DOMString) {
let element = ElementCast::from_ref(self);
let length = parse_length(&value);
element.set_attribute(&Atom::from_slice("size"), AttrValue::Length(value, length));
}
}

impl VirtualMethods for HTMLFontElement {
@@ -100,7 +104,7 @@ impl VirtualMethods for HTMLFontElement {
match name {
&atom!("face") => AttrValue::from_atomic(value),
&atom!("size") => {
let length = parse_legacy_font_size(&value).and_then(|parsed| specified::Length::from_str(&parsed));
let length = parse_length(&value);
AttrValue::Length(value, length)
},
_ => self.super_type().unwrap().parse_plain_attribute(name, value),
@@ -133,3 +137,7 @@ impl HTMLFontElement {
}
}
}

fn parse_length(value: &str) -> Option<specified::Length> {
parse_legacy_font_size(&value).and_then(|parsed| specified::Length::from_str(&parsed))
}
@@ -20,6 +20,11 @@
var testSize = function (attrValue) {
elem.setAttribute("size", attrValue);
assert_equals(elem.getAttribute("size"), attrValue);
assert_equals(elem.size, attrValue);

elem.size = attrValue;
assert_equals(elem.getAttribute("size"), attrValue);
assert_equals(elem.size, attrValue);
}

var args = [];
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.