mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
HTMLStyleElement only applies CSS in the document
HTMLStyleElement will not parse a style element created in Javascript until it is attached to the DOM. I added a reftest for the given cases: * a style element is defined in the HTML code, * a style element is created in Javascript, CSS content is added to the element and the element is later attached to the document, * a style element is created in Javascript, attached to the document and later CSS content is added to the element, * a style element is created in Javascript, CSS content is added to the * element but the element is never attached to the document.
This commit is contained in:
parent
1e263f9dec
commit
c2345e930d
3 changed files with 60 additions and 1 deletions
28
src/test/ref/style_is_in_doc.html
Normal file
28
src/test/ref/style_is_in_doc.html
Normal file
|
@ -0,0 +1,28 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<style>
|
||||
.from_html { color: blue; }
|
||||
.is_not_in_doc { color: grey; }
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
var append_later = document.createElement('style');
|
||||
append_later.textContent = ".append_later { color: green; }";
|
||||
document.head.appendChild(append_later);
|
||||
|
||||
var text_set_later = document.createElement('style');
|
||||
document.head.appendChild(text_set_later);
|
||||
text_set_later.textContent = ".text_set_later { color: yellow; }";
|
||||
|
||||
var is_not_in_doc = document.createElement('style');
|
||||
is_not_in_doc = ".is_not_in_doc { color: red; }";
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<p class="from_html">Style from html element</p>
|
||||
<p class="append_later">Style from an element added in javascript</p>
|
||||
<p class="text_set_later">Style from an element with content set in javascript</p>
|
||||
<p class="is_not_in_doc">Style that is never in the document</p>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue