This repository has been archived by the owner on Mar 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
92 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
.red { | ||
background: red; | ||
background-color: red; | ||
} | ||
|
||
.overridden { | ||
background-color: green; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
.blue { | ||
background: blue; | ||
background-color: blue; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
.orange { | ||
background: orange; | ||
background-color: orange; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<style> | ||
.styled { | ||
background: red; | ||
} | ||
</style> | ||
<style> | ||
.overridden-style { | ||
background: red; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
<link rel="stylesheet" href="sheet3.css"> | ||
<link rel="stylesheet" href="sheet1.css"> | ||
<template> | ||
<link rel="stylesheet" href="sheet2.css"> | ||
</template> | ||
<link rel="stylesheet" href="sheet2.css"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,58 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>Style Links Test</title> | ||
<script src="../../../tools/test/htmltest.js"></script> | ||
<script src="../../../tools/test/chai/chai.js"></script> | ||
<script src="../../html-imports.js"></script> | ||
<link rel="import" href="imports/style-links-import.html"> | ||
</head> | ||
<body> | ||
<script> | ||
addEventListener('HTMLImportsLoaded', function() { | ||
|
||
function checkLinksForContent(root) { | ||
var links = root.querySelectorAll('link'); | ||
Array.prototype.forEach.call(links, function(link) { | ||
chai.assert.ok(link.__resource, 'style link loaded', link); | ||
}) | ||
} | ||
|
||
setTimeout(function() { | ||
checkLinksForContent(document.body); | ||
done(); | ||
return; | ||
|
||
var imp = document.head.querySelector('link[rel=import]'); | ||
chai.assert.ok(imp.content, 'import has content'); | ||
|
||
var styleLink = document.querySelector('link[rel=stylesheet]'); | ||
chai.assert.isUndefined(styleLink.__resource); | ||
|
||
checkLinksForContent(imp.content.querySelector('body')); | ||
|
||
chai.assert.equal(document.styleSheets.length, 2); | ||
|
||
done(); | ||
}, 50); | ||
}); | ||
</script> | ||
</body> | ||
<head> | ||
<title>Style Links Test</title> | ||
<script src="../../../tools/test/htmltest.js"></script> | ||
<script src="../../../tools/test/chai/chai.js"></script> | ||
<script src="../../html-imports.js"></script> | ||
<link rel="import" href="imports/style-links-import.html"> | ||
<style> | ||
.overridden { | ||
background-color: black; | ||
} | ||
</style> | ||
<link rel="import" href="imports/style-elements-import.html"> | ||
<style> | ||
.overridden-style { | ||
background-color: black; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="red">red?</div> | ||
<div class="blue">white?</div> | ||
<div class="orange">orange?</div> | ||
|
||
<div class="overridden">black?</div> | ||
|
||
<div class="styled">red?</div> | ||
<div class="overridden-style">black?</div> | ||
|
||
|
||
<script> | ||
addEventListener('HTMLImportsLoaded', function() { | ||
|
||
var imp = document.head.querySelector('link[rel=import]'); | ||
chai.assert.ok(imp.import, 'import has content'); | ||
|
||
function computedStyle(selector) { | ||
return getComputedStyle(document.querySelector(selector)); | ||
} | ||
|
||
// styles in stylesheets are applied | ||
chai.assert.equal(computedStyle('.red').backgroundColor, 'rgb(255, 0, 0)'); | ||
chai.assert.equal(computedStyle('.orange').backgroundColor, 'rgb(255, 165, 0)'); | ||
chai.assert.equal(computedStyle('.blue').backgroundColor, 'rgb(0, 0, 255)'); | ||
// styles in stylesheets are applied in the correct order and overriddable | ||
chai.assert.equal(computedStyle('.overridden').backgroundColor, 'rgb(0, 0, 0)'); | ||
// styles in style elements are applied | ||
chai.assert.equal(computedStyle('.styled').backgroundColor, 'rgb(255, 0, 0)'); | ||
// styles in style are applied in the correct order and overriddable | ||
chai.assert.equal(computedStyle('.overridden-style').backgroundColor, 'rgb(0, 0, 0)'); | ||
|
||
|
||
done(); | ||
}); | ||
</script> | ||
</body> | ||
</html> |