mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Return None as style for elements not in a document
This commit is contained in:
parent
acbca7b3aa
commit
36145d0686
2 changed files with 11 additions and 0 deletions
|
@ -99,6 +99,11 @@ impl<'a> PrivateCSSStyleDeclarationHelpers for &'a CSSStyleDeclaration {
|
||||||
fn get_computed_style(self, property: &Atom) -> Option<DOMString> {
|
fn get_computed_style(self, property: &Atom) -> Option<DOMString> {
|
||||||
let owner = self.owner.root();
|
let owner = self.owner.root();
|
||||||
let node = NodeCast::from_ref(owner.r());
|
let node = NodeCast::from_ref(owner.r());
|
||||||
|
if !node.is_in_doc() {
|
||||||
|
// TODO: Node should be matched against the style rules of this window.
|
||||||
|
// Firefox is currently the only browser to implement this.
|
||||||
|
return None;
|
||||||
|
}
|
||||||
let addr = node.to_trusted_node_address();
|
let addr = node.to_trusted_node_address();
|
||||||
window_from_node(owner.r()).resolved_style_query(addr, self.pseudo.clone(), property)
|
window_from_node(owner.r()).resolved_style_query(addr, self.pseudo.clone(), property)
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,12 @@
|
||||||
assert_equals(getComputedStyle(div, '::after').getPropertyValue("color"), "");
|
assert_equals(getComputedStyle(div, '::after').getPropertyValue("color"), "");
|
||||||
}, "Missing :after pseudoelement");
|
}, "Missing :after pseudoelement");
|
||||||
|
|
||||||
|
test(function() {
|
||||||
|
var div = document.createElement("div");
|
||||||
|
div.id = "foo";
|
||||||
|
assert_equals(getComputedStyle(div).getPropertyValue("width"), "");
|
||||||
|
}, "Blank style for elements not in a document");
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue