Skip to content

DOMElement.onShow should not update display property to block when its node.isShown() is false #470

Open
@panarch

Description

@panarch

Here's an example to test.

  1. Add parent node and two child nodes(child1, child2)
  2. Run child1.hide()
  3. Run parent node.hide()
  4. Run parent node.show()

In this case, child1(red) should not be displayed, but it does.

There might be two possible ways to fix this,

  1. Modify DOMElement.onShow not to change property when its Node.isShown() is false
  2. Modify Dispatch.show to ignore nodes which Node.isShown() is false

I think although Node.isShown() is false, Node would be better to get onShow events from Dispatch.
So I chose the first one to fix this.
How do you think?

'use strict';

// Famous dependencies
var DOMElement = require('famous/dom-renderables/DOMElement');
var FamousEngine = require('famous/core/FamousEngine');

FamousEngine.init();
var node = FamousEngine.createScene().addChild();
var child1 = node.addChild();
var child2 = node.addChild();

child1.el = new DOMElement(child1, {
    tagName: 'div',
    properties: {
        'background-color': 'red'
    }
});

child2.el = new DOMElement(child2, {
    tagName: 'div',
    properties: {
        'background-color': 'blue'
    }
});

child1
    .setSizeMode('absolute', 'absolute')
    .setAbsoluteSize(100, 100)
    .setAlign(0.5, 0.5)
    .setMountPoint(0.5, 0.5)
    .setPosition(-50, 0);

child2
    .setSizeMode('absolute', 'absolute')
    .setAbsoluteSize(100, 100)
    .setAlign(0.5, 0.5)
    .setMountPoint(0.5, 0.5)
    .setPosition(50, 0);

child1.hide();
node.hide();
node.show();
/*
 * child1(red) should not be shown
 */

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions