-
|
I know it's possible to get a single data attribute from the DOM Crawler with $blocks->each(function (Crawler $node, $i) use ($componentHtml) {
$el = $node->attr('data-element');
// $elData = $node->data(); // this doesn't work.
}but is there a way to get an array of all the data attributes, like javascripts el.dataset? I guess I could iterate over all the children and extract the ones beginning with data-, but I'm wondering if there's already a tool to do that. Or maybe DOMCrawler isn't the right component to use? |
Beta Was this translation helpful? Give feedback.
Answered by
MatTheCat
Dec 29, 2024
Replies: 1 comment 3 replies
-
|
Iterating over attributes is trivial so I’m not sure you’d need a dedicated tool. I guess you could try adding the crawler this functionality in a PR. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The crawler exposes a
getNodemethod returning aDOMNode, which exposes an$attributesproperty yieldingDomAttrs: