mirror of
https://github.com/Polymer/polymer.git
synced 2025-02-25 18:55:30 -06:00
119 lines
3.4 KiB
HTML
119 lines
3.4 KiB
HTML
<!doctype html>
|
|
<!--
|
|
@license
|
|
Copyright (c) 2017 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
|
|
-->
|
|
<html>
|
|
<head>
|
|
<script src="../../node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.js"></script>
|
|
<script src="wct-browser-config.js"></script>
|
|
<script src="../../node_modules/wct-browser-legacy/browser.js"></script>
|
|
<script type="module" src="../../polymer-legacy.js"></script>
|
|
<script type="module" src="./shady-unscoped-style-import.js"></script>
|
|
</head>
|
|
<body>
|
|
|
|
<custom-style>
|
|
<style is="custom-style">
|
|
html {
|
|
--foo: {
|
|
padding: 10px;
|
|
}
|
|
}
|
|
</style>
|
|
</custom-style>
|
|
|
|
<dom-module id="my-element">
|
|
|
|
<template>
|
|
<style include="global-shared1 global-shared2">
|
|
:host {
|
|
display: block;
|
|
}
|
|
|
|
.happy {
|
|
@apply --foo;
|
|
}
|
|
</style>
|
|
<div id="fromStyle" class="happy">Happy: green</div>
|
|
<div id="fromImport" class="import">Happy: yellow</div>
|
|
<div id="normal" class="normal">Happy: orange</div>
|
|
</template>
|
|
|
|
<script type="module">
|
|
import './shady-unscoped-style-import.js';
|
|
import { Polymer } from '../../lib/legacy/polymer-fn.js';
|
|
Polymer({
|
|
is: 'my-element'
|
|
});
|
|
</script>
|
|
|
|
</dom-module>
|
|
|
|
<dom-module id="my-element2">
|
|
|
|
<template>
|
|
<style include="global-shared1">
|
|
:host {
|
|
display: block;
|
|
}
|
|
|
|
</style>
|
|
<div id="fromStyle" class="happy">Happy: green</div>
|
|
<div id="fromImport" class="import">Happy: yellow</div>
|
|
<div id="normal" class="normal">Happy: orange</div>
|
|
</template>
|
|
|
|
<script type="module">
|
|
import './shady-unscoped-style-import.js';
|
|
import { Polymer } from '../../lib/legacy/polymer-fn.js';
|
|
Polymer({ is: 'my-element2'});
|
|
</script>
|
|
|
|
</dom-module>
|
|
|
|
<my-element></my-element>
|
|
<my-element2></my-element2>
|
|
|
|
<script type="module">
|
|
import './shady-unscoped-style-import.js';
|
|
suite('shady-unscoped styles', function() {
|
|
|
|
function assertComputed(element, value, property, pseudo) {
|
|
var computed = getComputedStyle(element, pseudo);
|
|
property = property || 'border-top-width';
|
|
if (Array.isArray(value)) {
|
|
assert.oneOf(computed[property], value, 'computed style incorrect for ' + property);
|
|
} else {
|
|
assert.equal(computed[property], value, 'computed style incorrect for ' + property);
|
|
}
|
|
}
|
|
|
|
var el1 = document.querySelector('my-element');
|
|
var el2 = document.querySelector('my-element2');
|
|
|
|
test('unscoped styles apply', function() {
|
|
assertComputed(el1.$.fromStyle, '1px');
|
|
assertComputed(el2.$.fromStyle, '1px');
|
|
});
|
|
|
|
test('shared and @apply apply when used with unscoped styles', function() {
|
|
assertComputed(el1.$.fromStyle, '10px', 'padding-top');
|
|
assertComputed(el1.$.normal, '3px');
|
|
assertComputed(el2.$.normal, '3px');
|
|
});
|
|
|
|
test('@apply does not apply under ShadyDOM for shady-unscoped styles', function() {
|
|
assertComputed(el1.$.fromStyle, '0px', 'margin-top');
|
|
assertComputed(el2.$.fromStyle, '0px', 'margin-top');
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|