Skip to content

Commit

Permalink
Explicitly set display none on dom-* elements (#4821)
Browse files Browse the repository at this point in the history
  • Loading branch information
TimvdLippe authored Sep 2, 2017
1 parent 1a32f4d commit 65859b1
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 0 deletions.
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>

0 comments on commit 65859b1

Please sign in to comment.