-
Notifications
You must be signed in to change notification settings - Fork 249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Fix DOMElement#onShow, Node#show, hide (#470) #471
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -922,8 +922,8 @@ Node.prototype._vecOptionalSet = function _vecOptionalSet (vec, index, val) { | |
* @return {Node} this | ||
*/ | ||
Node.prototype.show = function show () { | ||
Dispatch.show(this.getLocation()); | ||
this._shown = true; | ||
Dispatch.show(this.getLocation()); | ||
return this; | ||
}; | ||
|
||
|
@@ -937,8 +937,8 @@ Node.prototype.show = function show () { | |
* @return {Node} this | ||
*/ | ||
Node.prototype.hide = function hide () { | ||
Dispatch.hide(this.getLocation()); | ||
this._shown = false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. |
||
Dispatch.hide(this.getLocation()); | ||
return this; | ||
}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -204,7 +204,7 @@ DOMElement.prototype.onDismount = function onDismount() { | |
* @return {undefined} undefined | ||
*/ | ||
DOMElement.prototype.onShow = function onShow() { | ||
this.setProperty('display', 'block'); | ||
if (this._node.isShown()) this.setProperty('display', 'block'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is an unnecessary change IMO. When There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @alexanderGugel Thanks for fast responding! Currently, once a parent node#show called, the parent node calls all the children's node#onShow and child nodes` DOMElement#onShow although some child nodes are manually hidden which should not be affected by a parent. So, it can break child nodes' visible state, there's an example to see it
In that link, I chose the first way, but if I take the second to fix, it might be like this below. Rather than changing DOMElement#onShow, changing Dispatch#show Wrapping by if (node.isShown()) {
if (node.onShow) node.onShow();
var components = node.getComponents();
for (var i = 0, len = components.length ; i < len ; i++)
if (components[i] && components[i].onShow)
components[i].onShow();
} Both cases, updating Node#_shown value should be processed before than calling Dispatch#show Thanks! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Good point. I doubt there is a good solution to this in the current architecture. If a parent node is hidden, all its children are hidden ( What I was suggesting (seems like I misunderstood the intention behind this PR), is that the node's show state should be updated in the Dispatch, not in the Node's |
||
}; | ||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally
this._shown
shouldn't be set here at all. Insteadnode._setShown(true);
should be called inDispatch#show
.