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

Explicitly set display none on dom-* elements #4821

Merged
merged 1 commit into from
Sep 2, 2017
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
1 change: 1 addition & 0 deletions lib/elements/dom-bind.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
}

connectedCallback() {
this.style.display = 'none';
this.render();
}

Expand Down
1 change: 1 addition & 0 deletions lib/elements/dom-if.html
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@

connectedCallback() {
super.connectedCallback();
this.style.display = 'none';
if (this.if) {
this.__debounceRender();
}
Expand Down
1 change: 1 addition & 0 deletions lib/elements/dom-repeat.html
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@

connectedCallback() {
super.connectedCallback();
this.style.display = 'none';
// only perform attachment if the element was previously detached.
if (this.__isDetached) {
this.__isDetached = false;
Expand Down
61 changes: 61 additions & 0 deletions test/smoke/dom-if.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<!doctype html>
<html>
<head>
<link rel="import" href="../../polymer.html">
</head>
<body>


<dom-module id="my-element">

<template>
<style>
:host {
display: block;
}
.parent {
border: 1px solid red;
justify-content: space-between;
width: 300px;
display: flex;
}
.child {
border: 1px solid green;
width: 100px;
}
</style>
<div class='parent'>
<div class='child'>Child1</div>
<template is='dom-if' if='1'>
<div class='child'>Child2</div>
</template>
</div>
</template>


<!-- Uncomment for class syntax -->
<script>
class MyElement extends Polymer.Element {
static get is() { return 'my-element'; }
static get properties() {
return {
prop: {
type: String
}
}
}
constructor() {
super();
this.prop = 'my-element'
}
}
customElements.define(MyElement.is, MyElement);

</script>

</dom-module>

<my-element></my-element>

</body>
</html>