Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix style scope issues in dynamically named slotted items #108

Merged
merged 1 commit into from
May 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/vaadin-split-layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@
<div part="handle"></div>
</div>
<slot id="secondary" name="secondary"></slot>

<div hidden>
<!-- Workaround to fix a Shady style scoping issue caused by dynamic slot naming of the child elements (primary/secondary) -->
<slot></slot>
</div>
</template>

<script>
Expand Down
37 changes: 37 additions & 0 deletions test/observer-component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<link rel="import" href="../../polymer/polymer-element.html">
<link rel="import" href="../../polymer/lib/utils/flattened-nodes-observer.html">

<dom-module id="observer-component">
<template>
<style>
.bluetext {
color: rgb(0, 0, 255);
}
</style>
</template>
</dom-module>

<script>
class ObserverComponent extends Polymer.Element {

static get is() {
return 'observer-component';
}

ready() {
super.ready();
this._observer = new Polymer.FlattenedNodesObserver(this, info => {
this._blueText = document.createElement('div');
this._blueText.classList.add('bluetext');
this._blueText.innerHTML = 'blue';
this.shadowRoot.appendChild(this._blueText);
});
}

getTextColor() {
return getComputedStyle(this._blueText).color;
}
}

customElements.define(ObserverComponent.is, ObserverComponent);
</script>
36 changes: 36 additions & 0 deletions test/style-scope.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!doctype html>

<html>
<head>
<title>vaadin-split-layout test</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
<script src="../../web-component-tester/browser.js"></script>
<link rel="import" href="./observer-component.html">
<link rel="import" href="../vaadin-split-layout.html">
</head>
<body>

<vaadin-split-layout>
<observer-component>
<div></div>
</observer-component>
<div>Bar</div>
<div id="invisible">Baz</div>
</vaadin-split-layout>

<script>
describe('style scope', () => {
it('should have the right color', () => {
const observerComponent = document.querySelector('observer-component');
expect(observerComponent.getTextColor()).to.equal('rgb(0, 0, 255)');
});

it('should not display the third element', () => {
const invisible = document.querySelector('#invisible');
expect(invisible.clientHeight).to.equal(0);
});
});
</script>
</body>
</html>
3 changes: 2 additions & 1 deletion test/test-suites.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
window.VaadinSplitLayoutSuites = [
'vaadin-split-layout_test.html'
'vaadin-split-layout_test.html',
'style-scope.html',
];