Skip to content
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
Closed

All treeitem tag have children #1361

xieyu33333 opened this issue Nov 17, 2015 · 12 comments
Assignees
Milestone

Comments

@xieyu33333
Copy link
Contributor

@xieyu33333 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
Copy link

@lloydzhou lloydzhou commented Nov 17, 2015

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

Loading

@xieyu33333
Copy link
Contributor Author

@xieyu33333 xieyu33333 commented Nov 17, 2015

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

Loading

@lloydzhou
Copy link

@lloydzhou 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.

Loading

@GianlucaGuarini
Copy link
Member

@GianlucaGuarini GianlucaGuarini commented Nov 20, 2015

@xieyu33333 can you please make a jsfiddle example?

Loading

@xieyu33333
Copy link
Contributor Author

@xieyu33333 xieyu33333 commented Nov 25, 2015

Loading

@acousticseagull
Copy link

@acousticseagull 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/

Loading

@acousticseagull
Copy link

@acousticseagull 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.

Loading

@xieyu33333
Copy link
Contributor Author

@xieyu33333 xieyu33333 commented Nov 25, 2015

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

Loading

@acousticseagull
Copy link

@acousticseagull 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>

Loading

@GianlucaGuarini
Copy link
Member

@GianlucaGuarini GianlucaGuarini commented Dec 18, 2015

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

Loading

@GianlucaGuarini
Copy link
Member

@GianlucaGuarini 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

Loading

@GianlucaGuarini GianlucaGuarini self-assigned this Dec 18, 2015
@GianlucaGuarini GianlucaGuarini added this to the 3.0.0 milestone Mar 3, 2016
@GianlucaGuarini
Copy link
Member

@GianlucaGuarini GianlucaGuarini commented Oct 15, 2016

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

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants