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

All treeitem tag have children #1361

Closed
xieyu33333 opened this Issue Nov 17, 2015 · 12 comments

Comments

Projects
None yet
4 participants
@xieyu33333
Contributor

xieyu33333 commented Nov 17, 2015

<tree>
    <div class="tree-item-wrap" each="{ data }" onselectstart="return false" ondragstart="return false">
        <div class="tree-item-row { root: level==1 }" onclick="{ select }" style="padding-left: { countPadding(level) }">
            <i class="tree-item-arrow" onclick="{ toggle }" if="{ children }"></i>
            <div>{ name }</div>
        </div>
        <ul class="tree-child-wrap" if={ isFolder() }>
            <tree data="{ children }"></tree>
        </ul>
    </div>

   <script> ......</script>
</tree>

My code like that, and I find I can't use children to judge the arrow's exist; All item tag have children property, even the item data not have children.

@lloydzhou

This comment has been minimized.

Show comment
Hide comment
@lloydzhou

lloydzhou Nov 17, 2015

the child tree can judge count and trigger parent event to disable arrow.

lloydzhou commented Nov 17, 2015

the child tree can judge count and trigger parent event to disable arrow.

@xieyu33333

This comment has been minimized.

Show comment
Hide comment
@xieyu33333

xieyu33333 Nov 17, 2015

Contributor

@lloydzhou but this.children should be undefined at the leaf node

Contributor

xieyu33333 commented Nov 17, 2015

@lloydzhou but this.children should be undefined at the leaf node

@lloydzhou

This comment has been minimized.

Show comment
Hide comment
@lloydzhou

lloydzhou Nov 17, 2015

i mean do not check child from parent, only check in children tree and update parent "tree-item-arrow" class.

lloydzhou commented Nov 17, 2015

i mean do not check child from parent, only check in children tree and update parent "tree-item-arrow" class.

@GianlucaGuarini

This comment has been minimized.

Show comment
Hide comment
@GianlucaGuarini

GianlucaGuarini Nov 20, 2015

Member

@xieyu33333 can you please make a jsfiddle example?

Member

GianlucaGuarini commented Nov 20, 2015

@xieyu33333 can you please make a jsfiddle example?

@xieyu33333

This comment has been minimized.

Show comment
Hide comment
Contributor

xieyu33333 commented Nov 25, 2015

@acousticseagull

This comment has been minimized.

Show comment
Hide comment
@acousticseagull

acousticseagull Nov 25, 2015

For each of the children put an empty children array and then just check if the children array has a length. I've updated your fiddle https://jsfiddle.net/bj3fcb7v/2/

acousticseagull commented Nov 25, 2015

For each of the children put an empty children array and then just check if the children array has a length. I've updated your fiddle https://jsfiddle.net/bj3fcb7v/2/

@acousticseagull

This comment has been minimized.

Show comment
Hide comment
@acousticseagull

acousticseagull Nov 25, 2015

Actually you could do it like this also. https://jsfiddle.net/pk8wgxds/ which may be closer to what you were looking for.

acousticseagull commented Nov 25, 2015

Actually you could do it like this also. https://jsfiddle.net/pk8wgxds/ which may be closer to what you were looking for.

@xieyu33333

This comment has been minimized.

Show comment
Hide comment
@xieyu33333

xieyu33333 Nov 25, 2015

Contributor

At the old version, http://jsfiddle.net/bj3fcb7v/1/ is OK, I think it is a bug

Contributor

xieyu33333 commented Nov 25, 2015

At the old version, http://jsfiddle.net/bj3fcb7v/1/ is OK, I think it is a bug

@acousticseagull

This comment has been minimized.

Show comment
Hide comment
@acousticseagull

acousticseagull Nov 25, 2015

Yeah it seems like children should be undefined, but it's like it doesn't exist.

<tree each={ data }>
  { console.log(children) } // logs nothing
</tree>
<tree each={ item, i in data }>
  { console.log(children) } // logs undefined
</tree>

acousticseagull commented Nov 25, 2015

Yeah it seems like children should be undefined, but it's like it doesn't exist.

<tree each={ data }>
  { console.log(children) } // logs nothing
</tree>
<tree each={ item, i in data }>
  { console.log(children) } // logs undefined
</tree>
@GianlucaGuarini

This comment has been minimized.

Show comment
Hide comment
@GianlucaGuarini

GianlucaGuarini Dec 18, 2015

Member

does this issue still exists in riot 2.3.12 I am unable to reproduce this issue

Member

GianlucaGuarini commented Dec 18, 2015

does this issue still exists in riot 2.3.12 I am unable to reproduce this issue

@GianlucaGuarini

This comment has been minimized.

Show comment
Hide comment
@GianlucaGuarini

GianlucaGuarini Dec 18, 2015

Member

ah I probably know what's the issue.. the children property gets inherited from the parent if it's undefined that's why items without any children appears to have them as well this seems to be a bug

Member

GianlucaGuarini commented Dec 18, 2015

ah I probably know what's the issue.. the children property gets inherited from the parent if it's undefined that's why items without any children appears to have them as well this seems to be a bug

@GianlucaGuarini GianlucaGuarini added bug and removed question labels Dec 18, 2015

@GianlucaGuarini GianlucaGuarini self-assigned this Dec 18, 2015

@GianlucaGuarini GianlucaGuarini added this to the 3.0.0 milestone Mar 3, 2016

@GianlucaGuarini

This comment has been minimized.

Show comment
Hide comment
@GianlucaGuarini
Member

GianlucaGuarini commented Oct 15, 2016

fixed in riot@3.0.0 http://jsfiddle.net/rx7aw7u8/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment