-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
DomCrawler component Crawler::innerText() doesn't get text after a child node #48682
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
Labels
Comments
otsch
added a commit
to otsch/dom-crawler
that referenced
this issue
Dec 16, 2022
Fixes the issue described in symfony/symfony#48682 Further align the signature of the innerText() method with the text() method by adding optional default value and normalizeWhitespace arguments and extract normalizing whitespace to a shared method.
This was referenced Dec 16, 2022
fabpot
added a commit
that referenced
this issue
Jan 11, 2023
…rawler::innerText()` and make it return the first non-empty text (otsch) This PR was merged into the 6.3 branch. Discussion ---------- [DomCrawler] Add argument `$normalizeWhitespace` to `Crawler::innerText()` and make it return the first non-empty text This is a new PR instead of #48684 with target branch 6.3 as requested. | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #48682 | License | MIT Commits ------- bb0c214 [DomCrawler] Add argument `$normalizeWhitespace` to `Crawler::innerText()` and make it return the first non-empty text
fabpot
added a commit
that referenced
this issue
Aug 1, 2023
…ty string (NanoSector) This PR was submitted for the 6.4 branch but it was merged into the 6.3 branch instead. Discussion ---------- [Crawler] Fix regression where cdata nodes will return empty string | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | N/A | License | MIT | Doc PR | N/A <!-- Replace this notice by a short README for your feature/bugfix. This will help reviewers and should be a good start for the documentation. Additionally (see https://symfony.com/releases): - Always add tests and ensure they pass. - Bug fixes must be submitted against the lowest maintained branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too). - Features and deprecations must be submitted against the latest branch. - For new features, provide some code snippets to help understand usage. - Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry - Never break backward compatibility (see https://symfony.com/bc). --> Fixes a regression caused by the fix to #48682 where `<script>` tags would return empty string on the innerContent call, where in 6.2 this did work. Attached is a zipped PHPUnit test case used to verify the regression on 6.2 with a screenshot of its result. [CrawlerInnerTextTest.zip](https://github.com/symfony/symfony/files/10567760/CrawlerInnerTextTest.zip)  Commits ------- 23c1dda [Crawler] Fix regression where cdata nodes will return empty string
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Symfony version(s) affected
5.4
Description
The test case for this method basically is:
Getting
$crawler->text()
then returnsParent text Child text
and$crawler->innerText()
returnsParent text
. So far, so good.If I don't misunderstand anything, in case of:
the return value of
$crawler->innerText()
should beParent text More parent text
. But it's still justParent text
.I'll provide a pull request to fix this in a minute.
How to reproduce
In the
Tests/AbstractCrawlerTest.php
test file, adapt the HTML in thecreateTestCrawler()
method from:to
And the
testInnerText()
method accordingly to:Possible Solution
#48684
Additional Context
No response
The text was updated successfully, but these errors were encountered: