-
Notifications
You must be signed in to change notification settings - Fork 6
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
[HOTFIX] Content parser selectors #65
Conversation
Thanks for making this PR @Zamfi99, we will look into this fix 👍🏾 |
@Zamfi99 Thank you for this report! Can you give an example of markup where you see this issue, so we can understand it better? Thank you! Here's a template you can use: Gutenberg Markup<!-- wp:paragraph -->
<p>Some example HTML from the block editor...</p>
<!-- /wp:paragraph --> Block Data API Result[{
"name": "core/paragraph",
"attributes": {
"content": "Some example HTML from the block editor..."
}
}] Expected Result
|
2275d17
to
17c947b
Compare
@alecgeatches Sure thing. I've also made some changes and updated the PR description. Gutenberg Markup<!-- wp:image {"id":563,"sizeSlug":"large","linkDestination":"none","sfsBlockId":"811c30a5-1213-440f-a2a9-ee9ec3b4936e","className":"additional-css-class","credit":"","orientationOnMobile":"vertical"} -->
<figure class="wp-block-image size-large additional-css-class" id="anchor">
<img src="https://example.com" alt="alt" class="wp-image-563" title="title"/>
<figcaption class="wp-element-caption">Caption.</figcaption>
</figure>
<!-- /wp:image --> Block Data API Result[
{
"id": "QmxvY2tEYXRhOjcxNDox",
"name": "core/image",
"attributes": [
{
"name": "id",
"value": "563",
"isValueJsonEncoded": true
},
// removed the other attributes
{
"name": "anchor",
"value": "",
"isValueJsonEncoded": false
}
],
"innerBlocks": null
}
] Expected Result[
{
"id": "QmxvY2tEYXRhOjcxNDox",
"name": "core/image",
"attributes": [
{
"name": "id",
"value": "563",
"isValueJsonEncoded": true
},
// removed the other attributes
{
"name": "anchor",
"value": "anchor",
"isValueJsonEncoded": false
}
],
"innerBlocks": null
}
] ClarificationBy running [
{
"anchor": {
"attribute": "id",
"selector": "*",
"source": "attribute",
"type": "string"
}
}
] |
Hello @Zamfi99! I've opened up a second PR based on these changes in #71. The main differences:
If you have time, feel free to take a look at those changes before they're merged and ensure they address your issue. I'll plan to merge them in tomorrow. |
I'm going to close this issue for now. We've added a fix for Thank you for your input and feedback in this and related issues! |
Description
For some specific use cases, such as retrieving the anchor attributes from the HTML of every block, the API may unexpectedly return
null
.For example:
*
) then the first node returned by$crawler->filter( $selector );
will be thebody
element that doesn't contain any attribute, so the$crawler->attr( $attribute );
will always returnnull
.To avoid this outcome, we can modify the
source_block_attribute
method in order to filter the elements within thebody
element.Steps to Test
composer run test
.