We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Reference: https://github.com/FluentDOM/FluentDOM/wiki/Query-Get
For my understanding, get() should return only 1 element. Why does it return an array containing an element instead of the element?
get()
var href = $('<div><a href="/1">1</a><a href="/2">2</a><a href="/3">3</a></div>').find("a").get(0).getAttribute("href");
/1
$href = FluentDom::QueryCss('<div><a href="/1">1</a><a href="/2">2</a><a href="/3">3</a></div>', "html-fragment")->find("a")->get(0)->getAttribute("href");
$document = FluentDom::QueryCss('<div><a href="/1">1</a><a href="/2">2</a><a href="/3">3</a></div>', "html-fragment"); $href = ''; if ( $linkDom = $document->find("a")->get(0)[0] ) { $href = $linkDom->getAttribute("href"); }
The text was updated successfully, but these errors were encountered:
It's an bug. Not sure how that happened. I don't think I can just fix it in a minor version to old and it might break things.
However FluentDOM::Query allows ArrayAccess, so this does work:
FluentDOM::Query
$fd = FluentDom::Query('<div><a href="/1">1</a><a href="/2">2</a><a href="/3">3</a></div>', "html-fragment"); $href = $fd->find("//a")[0]['href']; var_dump($href);
Sorry, something went wrong.
a4177b1
ThomasWeinert
No branches or pull requests
Reference: https://github.com/FluentDOM/FluentDOM/wiki/Query-Get
For my understanding,
get()
should return only 1 element. Why does it return an array containing an element instead of the element?JQuery Version
Code:
Result:
FluentDom Version
Expected Code:
Actual Code:
The text was updated successfully, but these errors were encountered: