Skip to content

children method does not return duplicate children #1275

@WeishenMead

Description

@WeishenMead

Calling node.children() does not always return duplicate children (instead it removes them). It looks like this is because children uses flatMap internally, and flatMap dedupes its entries.

Somewhat trivial test case:

render() {
  const foo = 'Foo';
  return (
    <div>
      {foo} Bar {foo} Bar {foo}
    </div>
  )
}

In this case I would expect:
node.children() === ['Foo', 'Bar', 'Foo', 'Bar', 'Foo']

but instead we get:
node.children() === ['Foo', 'Bar']

I tested this in version 2.9.1, but looking at the code I think it should still exist in master.

I think the right solution is to not use de-dupe in flatMap, but I'm not sure if there's a reason that was added in to begin with.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions