Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
WP_HTML_Tag_Processor: Add
get_attribute_names_with_prefix()
method #46840WP_HTML_Tag_Processor: Add
get_attribute_names_with_prefix()
method #46840Changes from 10 commits
4e4b957
1573010
8be4ac9
8c51859
ca06c64
2dbf838
5b248c0
5f3e9ff
0c61498
a9d8ec3
8a8c1e2
263cfa1
a4b1071
37c94c3
ca46027
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I like this, but I want to make sure we aren't overlooking the possibility of wanting to return
array()
when not on a tag. It feels like the kind of thing where I might have suggested the opposite: returnnull
if we're not on a tag 🙃 but oh well - is there a reason to differentiate between "there are no attributes matching this prefix" and "you shouldn't be calling this here"?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, good point. I don't feel strongly about this -- it used to return
array()
prior to this commit.I think my chief reason to change it to
null
was consistency with both the "not-on-a-tag" case, andget_attribute()
's behavior when on a closing tag (for which I even added a test case, 8c51859) -- thinking thatnull
made sense as the general indicator for "no attributes here".But an empty array might make just as much sense.
To push this further, would it then make sense to return
array()
also ifnull === $this->tag_name_starts_at
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it doesn't seem like it'd matter to me to differentiate why you didn't call it in the right place, only that you did call it from the wrong place.
if we return
null
we know people will end up writing code that crashes because they won't check the results. if we return an empty array we know that people will introduce data corruption by assuming it worked.while it may fluctuate on a weekly basis, I think given this thought I lean towards
null
which at least gives a way to know more clearly if something is missing attributes or that we're looking at the wrong spot in the document.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy to stick with
null
😊 👍