Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[DomCrawler] Added Crawler::innerText() method#42338

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:5.4fromBilge:innerText
Sep 21, 2021

Conversation

@Bilge
Copy link
Contributor

QA
Branch?5.4
Bug fix?no
New feature?yes
Deprecations?no
TicketsFix#42294
LicenseMIT
Doc PRsymfony/symfony-docs#...

Adds a method to get the inner text that is directly descended from the current node only, ignoring text nodes in any child nodes.

Comment on lines +357 to +360
/**
* Tests that innerText() returns only text that is the direct descendent of the current node, in contrast to
* text() that returns the text of all child nodes.
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

The comment is not needed

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

A test scenario is not needed, in a technical sense, but it is needed in a maintainability sense. It conveys what the original intent of the test is, which helps greatly in determining how to fix it when it should break in future.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

From my POV we can keep it, buttestInnerText() method name makes clear what's the point here 🤷‍♂️

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Perhaps, but I think writing test scenarios is a good habit to be into.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Do we use this anywhere else in the DomCrawler's test suite? If not, I am in favour of removing the comment and, if necessary, change the method name to something liketestInnerTextReturnsContentOfDirectDescendantTextNodesExclusively().

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Strongly disagree. Prose is much easier to read as space-separated words instead of stuffing entire sentences into camel-cased method names.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

in this casetestInnerText() is enough

@carsonbotcarsonbot changed the titleAdded Crawler::innerText() method[DomCrawler] Added Crawler::innerText() methodAug 1, 2021
@OskarStarkOskarStark added this to the5.4 milestoneAug 1, 2021
*/
publicfunctioninnerText():string
{
return$this->filterXPath('.//text()')->text();
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This can also be expressed aschild::node()/text(). I don't know which is "better".

@fabpot
Copy link
Member

@Bilge Can you take suggestions into account?

@Bilge
Copy link
ContributorAuthor

@fabpot Suggestions have been taken into account.

@fabpot
Copy link
Member

Thank you@Bilge.

@fabpotfabpot merged commit0ddeeff intosymfony:5.4Sep 21, 2021
@BilgeBilge deleted the innerText branchOctober 2, 2021 09:54
This was referencedNov 5, 2021
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@OskarStarkOskarStarkOskarStark left review comments

@xabbuhxabbuhxabbuh left review comments

@fabpotfabpotfabpot approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

5.4

Development

Successfully merging this pull request may close these issues.

Get direct descendent text only when calling text() on a node.

5 participants

@Bilge@fabpot@OskarStark@xabbuh@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp