mirror of
https://github.com/jlengrand/webcomponentsjs.git
synced 2026-03-10 08:51:22 +00:00
Avoid loading style/link elements with type attribute; ensure that load event fired by setting style.textContent (FF only) is ignored.
This commit is contained in:
@@ -32,8 +32,8 @@ var importParser = {
|
||||
// parse selectors for import document elements
|
||||
importsSelectors: [
|
||||
IMPORT_SELECTOR,
|
||||
'link[rel=stylesheet]',
|
||||
'style',
|
||||
'link[rel=stylesheet]:not([type])',
|
||||
'style:not([type])',
|
||||
'script:not([type])',
|
||||
'script[type="application/javascript"]',
|
||||
'script[type="text/javascript"]'
|
||||
@@ -178,6 +178,10 @@ var importParser = {
|
||||
trackElement: function(elt, callback) {
|
||||
var self = this;
|
||||
var done = function(e) {
|
||||
// make sure we don't get multiple load/error signals (FF seems to do
|
||||
// this sometimes when <style> elments change)
|
||||
elt.removeEventListener('load', done);
|
||||
elt.removeEventListener('error', done);
|
||||
if (callback) {
|
||||
callback(e);
|
||||
}
|
||||
|
||||
13
tests/HTMLImports/html/imports/sheet4.css
Normal file
13
tests/HTMLImports/html/imports/sheet4.css
Normal file
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
||||
* This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
* The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
* The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
* Code distributed by Google as part of the polymer project is also
|
||||
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
*/
|
||||
|
||||
.link-typed {
|
||||
background-color: navy;
|
||||
}
|
||||
@@ -21,4 +21,10 @@
|
||||
.styled {
|
||||
background: red;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style type="foo">
|
||||
.style-typed {
|
||||
background: red;
|
||||
}
|
||||
</style>
|
||||
@@ -10,3 +10,5 @@
|
||||
<link rel="stylesheet" href="sheet3.css">
|
||||
<link rel="stylesheet" href="sheet1.css">
|
||||
<link rel="stylesheet" href="sheet2.css">
|
||||
|
||||
<link rel="stylesheet" type="foo" href="sheet4.css">
|
||||
|
||||
@@ -37,6 +37,10 @@
|
||||
<div class="styled">red?</div>
|
||||
<div class="overridden-style">black?</div>
|
||||
|
||||
<div class="link-typed">red?</div>
|
||||
|
||||
<div class="style-typed">red?</div>
|
||||
|
||||
|
||||
<script>
|
||||
addEventListener('HTMLImportsLoaded', function() {
|
||||
@@ -59,6 +63,10 @@
|
||||
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)');
|
||||
// links with type attr are not imported
|
||||
chai.assert.equal(computedStyle('.link-typed').backgroundColor, 'rgba(0, 0, 0, 0)');
|
||||
// styles with type attr are not imported
|
||||
chai.assert.equal(computedStyle('.style-typed').backgroundColor, 'rgba(0, 0, 0, 0)');
|
||||
|
||||
|
||||
done();
|
||||
|
||||
Reference in New Issue
Block a user