From 2d653be2a36057fa46596dca71f68f9f32494e5e Mon Sep 17 00:00:00 2001 From: Jeroen Versteeg Date: Thu, 20 Jun 2013 10:37:03 +0200 Subject: [PATCH 1/5] `Node.toggleView` did not show Node when `style="display: none"` `node-view`'s `_isHidden()` relied on `hidden` attribute, now also checks and `display` style (in line with `_hide` and `_show`) --- src/node/js/node-view.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/node/js/node-view.js b/src/node/js/node-view.js index 6b96acbef18..246fe0324d9 100644 --- a/src/node/js/node-view.js +++ b/src/node/js/node-view.js @@ -42,7 +42,8 @@ Y.mix(Y_Node.prototype, { }, _isHidden: function() { - return Y.DOM.getAttribute(this._node, 'hidden') === 'true'; + return Y.DOM.getAttribute(this._node, 'hidden') === 'true' + || Y.DOM.getStyle(this._node, 'display') === 'none'; }, /** From 9a586b057da75923b9d460f2a361ff57c71bfbaa Mon Sep 17 00:00:00 2001 From: Jeroen Versteeg Date: Thu, 20 Jun 2013 13:45:42 +0200 Subject: [PATCH 2/5] `node-view` requires `dom-style` --- src/node/meta/node.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/node/meta/node.json b/src/node/meta/node.json index 64416acc936..b127ac4ba93 100644 --- a/src/node/meta/node.json +++ b/src/node/meta/node.json @@ -52,7 +52,8 @@ "requires": [ "event-base", "node-core", - "dom-base" + "dom-base", + "dom-style" ] }, "node-event-delegate": { From 86d74fcb562f209b0c8d7269a6b34aac605390cc Mon Sep 17 00:00:00 2001 From: Jeroen Versteeg Date: Fri, 21 Jun 2013 09:33:01 +0200 Subject: [PATCH 3/5] Improved node-view's _isHidden See PR 895 --- src/node/js/node-view.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/node/js/node-view.js b/src/node/js/node-view.js index 246fe0324d9..7404576be25 100644 --- a/src/node/js/node-view.js +++ b/src/node/js/node-view.js @@ -42,8 +42,8 @@ Y.mix(Y_Node.prototype, { }, _isHidden: function() { - return Y.DOM.getAttribute(this._node, 'hidden') === 'true' - || Y.DOM.getStyle(this._node, 'display') === 'none'; + return this._node.hasAttribute('hidden') + || Y.DOM.getComputedStyle(this._node, 'display') === 'none'; }, /** From 993fe2cb67538c9a8ab6a423c67a16b787fee4e9 Mon Sep 17 00:00:00 2001 From: Jeroen Versteeg Date: Fri, 21 Jun 2013 23:07:06 +0200 Subject: [PATCH 4/5] `node-view` `_hide` sets `hidden` attribute to empty string That's what the spec says! See * http://dev.w3.org/html5/spec-preview/common-microsyntaxes.html#boolean-attributes * http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-F68F082 --- src/node/js/node-view.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node/js/node-view.js b/src/node/js/node-view.js index 7404576be25..a43a7f2e02f 100644 --- a/src/node/js/node-view.js +++ b/src/node/js/node-view.js @@ -108,7 +108,7 @@ Y.mix(Y_Node.prototype, { * @chainable */ _hide: function() { - this.setAttribute('hidden', true); + this.setAttribute('hidden', ''); // For back-compat we need to leave this in for browsers that // do not visually hide a node via the hidden attribute From 6189db73865f79405281f50af82aa5a9e5c9b2fc Mon Sep 17 00:00:00 2001 From: Jeroen Versteeg Date: Mon, 24 Jun 2013 11:19:30 +0200 Subject: [PATCH 5/5] Adjusted node-view tests to proper use of hidden attribute --- src/node/tests/unit/node.html | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/node/tests/unit/node.html b/src/node/tests/unit/node.html index 8b034300eec..66c59b82470 100644 --- a/src/node/tests/unit/node.html +++ b/src/node/tests/unit/node.html @@ -1356,7 +1356,7 @@

test

'should hide the node': function() { var node = Y.one('body'); node.hide(); - Assert.areEqual('true', node.getAttribute('hidden')); + Assert.isTrue(node.hasAttribute('hidden')); Assert.areEqual('none', node.getStyle('display')); node.removeAttribute('hidden'); node.setStyle('display', 'block'); @@ -1364,10 +1364,10 @@

test

'should show the node': function() { var node = Y.one('body'); - node.setAttribute('hidden', true); + node.setAttribute('hidden', ''); node.setStyle('display', 'none'); node.show(1); - Assert.areEqual('', node.getAttribute('hidden')); + Assert.isFalse(node.hasAttribute('hidden')); Assert.areEqual('block', node.getStyle('display')); node.removeAttribute('hidden'); node.setStyle('display', 'block'); @@ -1377,7 +1377,7 @@

test

var node = Y.one('body'), called = false; - node.setAttribute('hidden', true); + node.setAttribute('hidden', ''); node.setStyle('display', 'none'); node.show(function() { @@ -1486,7 +1486,7 @@

test

node.toggleView(false); - Assert.areEqual('true', node.getAttribute('hidden')); + Assert.isTrue(node.hasAttribute('hidden')); Assert.areEqual('none', node.getStyle('display')); node.removeAttribute('hidden'); node.setStyle('display', 'block'); @@ -1501,7 +1501,7 @@

test

}); Assert.isTrue(called); - Assert.areEqual('true', node.getAttribute('hidden')); + Assert.isTrue(node.hasAttribute('hidden')); Assert.areEqual('none', node.getStyle('display')); node.removeAttribute('hidden'); node.setStyle('display', 'block');