question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Behavior of find and findAll

See original GitHub issue

Should find and findAll return all nodes including the root node, or excluding the root node

Including root node:

const compiled = compileToFunctions('<div><div /></div>')
const wrapper = mount(compiled).findAll('div').length // 2

excluding root node:

const compiled = compileToFunctions('<div><div /></div>')
const wrapper = mount(compiled).findAll('div').length // 1

I think it should exclude the root node, but would be interested to hear others thoughts

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:13 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
callumacraecommented, Jun 12, 2017

+1 to including the root node: if the root node is returned and the user wasn’t expecting it to, it’s clear what happened and easy to work around, while it’s less obvious the other way round.

2reactions
eddyerburghcommented, Jun 12, 2017

@Austio I don’t think we should add an extra find method. Two is enough.

I thought about it this weekend and I agree with @yyx990803 . We should include the root node, in every find and findAll call.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Different behavior between re.finditer and re.findall
But finditer and findall are finding different things. Findall indeed finds all the matches in the given string. But finditer only finds the...
Read more >
Python re.findall() – Everything You Need to Know - Finxter
This article is all about the findall() method of Python's re library. The findall() method is the most basic way of using regular...
Read more >
Beautiful Soup documentation - Crummy
The basic find method: findAll(name, attrs, recursive, text, limit, **kwargs). Searching by CSS class; Calling a tag is like calling findall.
Read more >
Python Regular Expressions - Google Developers
findall () is probably the single most powerful function in the re module. Above we used re.search() to find the first match for...
Read more >
Strange behavior of Find All in Current Document with ...
The search string now has \n inserted into it, and the Search Mode has been changed! This, of course, is why there are...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found