mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
Removing style element's styles when elements is removed from dom
This commit is contained in:
parent
b3ce08f1b5
commit
f0c72cb7fd
4 changed files with 59 additions and 1 deletions
|
@ -15,7 +15,7 @@ use dom::document::Document;
|
||||||
use dom::element::{Element, ElementCreator};
|
use dom::element::{Element, ElementCreator};
|
||||||
use dom::eventtarget::EventTarget;
|
use dom::eventtarget::EventTarget;
|
||||||
use dom::htmlelement::HTMLElement;
|
use dom::htmlelement::HTMLElement;
|
||||||
use dom::node::{ChildrenMutation, Node, document_from_node, window_from_node};
|
use dom::node::{ChildrenMutation, Node, UnbindContext, document_from_node, window_from_node};
|
||||||
use dom::stylesheet::StyleSheet as DOMStyleSheet;
|
use dom::stylesheet::StyleSheet as DOMStyleSheet;
|
||||||
use dom::virtualmethods::VirtualMethods;
|
use dom::virtualmethods::VirtualMethods;
|
||||||
use html5ever_atoms::LocalName;
|
use html5ever_atoms::LocalName;
|
||||||
|
@ -161,6 +161,15 @@ impl VirtualMethods for HTMLStyleElement {
|
||||||
self.parse_own_css();
|
self.parse_own_css();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn unbind_from_tree(&self, context: &UnbindContext) {
|
||||||
|
if let Some(ref s) = self.super_type() {
|
||||||
|
s.unbind_from_tree(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
let doc = document_from_node(self);
|
||||||
|
doc.invalidate_stylesheets();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl StylesheetOwner for HTMLStyleElement {
|
impl StylesheetOwner for HTMLStyleElement {
|
||||||
|
|
|
@ -6474,6 +6474,18 @@
|
||||||
"url": "/_mozilla/mozilla/remove_link_styles.html"
|
"url": "/_mozilla/mozilla/remove_link_styles.html"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"mozilla/remove_style_styles.html": [
|
||||||
|
{
|
||||||
|
"path": "mozilla/remove_style_styles.html",
|
||||||
|
"references": [
|
||||||
|
[
|
||||||
|
"/_mozilla/mozilla/remove_style_styles_ref.html",
|
||||||
|
"=="
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"url": "/_mozilla/mozilla/remove_style_styles.html"
|
||||||
|
}
|
||||||
|
],
|
||||||
"mozilla/reparse_style_elements.html": [
|
"mozilla/reparse_style_elements.html": [
|
||||||
{
|
{
|
||||||
"path": "mozilla/reparse_style_elements.html",
|
"path": "mozilla/reparse_style_elements.html",
|
||||||
|
@ -21876,6 +21888,18 @@
|
||||||
"url": "/_mozilla/mozilla/remove_link_styles.html"
|
"url": "/_mozilla/mozilla/remove_link_styles.html"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"mozilla/remove_style_styles.html": [
|
||||||
|
{
|
||||||
|
"path": "mozilla/remove_style_styles.html",
|
||||||
|
"references": [
|
||||||
|
[
|
||||||
|
"/_mozilla/mozilla/remove_style_styles_ref.html",
|
||||||
|
"=="
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"url": "/_mozilla/mozilla/remove_style_styles.html"
|
||||||
|
}
|
||||||
|
],
|
||||||
"mozilla/reparse_style_elements.html": [
|
"mozilla/reparse_style_elements.html": [
|
||||||
{
|
{
|
||||||
"path": "mozilla/reparse_style_elements.html",
|
"path": "mozilla/reparse_style_elements.html",
|
||||||
|
|
20
tests/wpt/mozilla/tests/mozilla/remove_style_styles.html
Normal file
20
tests/wpt/mozilla/tests/mozilla/remove_style_styles.html
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
<!doctype html>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Removing style element should remove all associated styles</title>
|
||||||
|
<link rel="match" href="remove_style_styles_ref.html">
|
||||||
|
<body>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
background-color: red;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
This text should be black and the background should not be red.
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// Force restyling
|
||||||
|
window.getComputedStyle(document.body);
|
||||||
|
var s = document.querySelector('style');
|
||||||
|
s.parentNode.removeChild(s);
|
||||||
|
</script>
|
||||||
|
</body>
|
|
@ -0,0 +1,5 @@
|
||||||
|
<!doctype html>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<body>
|
||||||
|
This text should be black and the background should not be red.
|
||||||
|
</body>
|
Loading…
Add table
Add a link
Reference in a new issue