Skip to content

Commit

Permalink
fix: starting at reverse true should now work
Browse files Browse the repository at this point in the history
  • Loading branch information
sbeleidy committed Mar 10, 2017
1 parent aa714e9 commit cbbf23c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 14 deletions.
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Easily reverse the order of children elements in the dom while maintaining grand
<link rel="import" href="../../reverse-element/reverse-element.html">
```

### Odd number of children
### Toggleable Reverse Element
<!--
```
<custom-element-demo>
Expand Down Expand Up @@ -70,13 +70,12 @@ Easily reverse the order of children elements in the dom while maintaining grand
</reverse-element>
```

### Even number of children
### Reversed

<!--
```
<custom-element-demo>
<template>
<link rel="import" href="../paper-toggle-button/paper-toggle-button.html">
<link rel="import" href="../paper-input/paper-input.html">
<link rel="import" href="reverse-element.html">
<div>
Expand All @@ -89,9 +88,7 @@ Easily reverse the order of children elements in the dom while maintaining grand
```
-->
```html
<paper-toggle-button checked="{{reverse}}"> Toggle Reverse</paper-toggle-button>

<reverse-element reverse="{{reverse}}">
<reverse-element reverse>
<div>
<h3>First</h3>
<paper-input label="First"></paper-input>
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "reverse-element",
"version": "0.0.3",
"version": "0.0.4",
"description": "Reverses child elements based on property - helpful for accessibility",
"main": "reverse-element.html",
"license": "MIT",
Expand Down
9 changes: 3 additions & 6 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<body>
<div class="vertical-section-container centered">
<h3>Basic odd reverse-element demo</h3>
<h3>Toggleable reverse-element demo</h3>
<demo-snippet>
<template is="dom-bind">

Expand Down Expand Up @@ -51,13 +51,10 @@ <h3>
</div>

<div class="vertical-section-container centered">
<h3>Basic even reverse-element demo</h3>
<h3>Reversed reverse-element demo</h3>
<demo-snippet>
<template is="dom-bind">

<paper-toggle-button checked="{{reverse2}}" toggles> Toggle Reverse</paper-toggle-button>

<reverse-element reverse="{{reverse2}}">
<reverse-element reverse>
<div>
<h3>First</h3>
<paper-input label="First"></paper-input>
Expand Down
2 changes: 1 addition & 1 deletion reverse-element.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
},
_reverse: function (newVal, oldVal) {
if (newVal != oldVal && oldVal != undefined) {
if ((newVal != oldVal && oldVal != undefined) || (newVal && oldVal==undefined) ) {
// loop from the bottom and remove
for (var i = this.childNodes.length - 1; i >= 0; i--) {
x = this.removeChild(this.childNodes[i]);
Expand Down

0 comments on commit cbbf23c

Please sign in to comment.