Skip to content

Commit

Permalink
Merge pull request #11235 from rwjblue/allow-isVisible-to-be-CP
Browse files Browse the repository at this point in the history
[BUGFIX beta] Allow `isVisible` to be a computed property.
  • Loading branch information
rwjblue committed May 20, 2015
2 parents c675839 + d1c424c commit 1ce6034
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ function normalizeComponentAttributes(component, isAngleBracket, attrs) {
normalized.class = normalizedClass;
}

if (component.isVisible === false) {
if (get(component, 'isVisible') === false) {
var hiddenStyle = ['value', "display: none;"];
var existingStyle = normalized.style;

Expand Down
25 changes: 24 additions & 1 deletion packages/ember-views/tests/views/view/is_visible_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { set } from "ember-metal/property_set";
import run from "ember-metal/run_loop";
import EmberView from "ember-views/views/view";
import ContainerView from "ember-views/views/container_view";
//import compile from "ember-template-compiler/system/compile";
import { computed } from "ember-metal/computed";

var View, view, parentBecameVisible, childBecameVisible, grandchildBecameVisible;
var parentBecameHidden, childBecameHidden, grandchildBecameHidden;
Expand Down Expand Up @@ -71,6 +71,29 @@ QUnit.test("should hide element if isVisible is false before element is created"
});
});

QUnit.test("should hide views when isVisible is a CP returning false", function() {
view = EmberView.extend({
isVisible: computed(function() {
return false;
})
}).create();

run(function() {
view.append();
});

ok(view.$().is(':hidden'), "the view is hidden");

run(function() {
set(view, 'isVisible', true);
});

ok(view.$().is(':visible'), "the view is visible");
run(function() {
view.remove();
});
});

QUnit.test("doesn't overwrite existing style attribute bindings", function() {
view = EmberView.create({
isVisible: false,
Expand Down

0 comments on commit 1ce6034

Please sign in to comment.