Skip to content

Commit

Permalink
fix error in visibility methods for empty node
Browse files Browse the repository at this point in the history
  • Loading branch information
chemerisuk committed Oct 10, 2017
1 parent 4f616d6 commit 0e0ecdc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/element/visibility.js
Expand Up @@ -15,8 +15,10 @@ function makeMethod(methodName, condition) {
}

const node = this["<%= prop() %>"];
const computed = computeStyle(node);

if (!node) return this;

const computed = computeStyle(node);
// Determine of we need animation by checking if an element
// has non-zero width. Triggers reflow but fixes animation
// for new elements inserted into the DOM in some browsers
Expand Down
8 changes: 8 additions & 0 deletions test/spec/element/visibility.spec.js
Expand Up @@ -57,6 +57,10 @@ describe("show", function() {
done();
});
});

it("does nothing for empty node", function() {
DOM.find("x-show").show();
});
});

describe("hide", function() {
Expand Down Expand Up @@ -97,4 +101,8 @@ describe("hide", function() {
done();
});
});

it("does nothing for empty node", function() {
DOM.find("x-hide").hide();
});
});

0 comments on commit 0e0ecdc

Please sign in to comment.