-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[5.2] Allowing menu items to have multiple 'rel' values #39269
base: 5.2-dev
Are you sure you want to change the base?
Conversation
Rel can have multiple values; we should allow that to happen.
Adding missing valid rel values per https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types
Must admit to never having seen this before. But following your links for adding missing values I see other values we have in our list that are not valid actually its just prefetch that isdwrong. The others that I thought were invalid are non standard values created by google and should be included |
Yes, I saw prefetch too (which doesn't actually do anything when it's on an |
@@ -156,13 +156,16 @@ public static function getList(&$params) | |||
$item->flink = Route::_($item->flink); | |||
} | |||
|
|||
// rel can now have multiple values, combine the array into a space-separated string | |||
$rel = is_array($itemParams->get('menu-anchor_rel')) ? implode(' ', $itemParams->get('menu-anchor_rel')) : $itemParams->get('menu-anchor_rel', ''); |
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 don't remember in Joomla Framework we have some method to join an array but it would be nice if we have something like,
$rel = ArrayHelper::join($itemParams->get('menu-anchor_rel'), ' ');
Then this code would have been very simple to read. 🤔
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.
The issue is that I'm also checking if it's an array or not, because prior values would be a string. I'm going to be looking if there's a better way to solve this though without breaking b/c.
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 100% agree with your code change in this PR. I was trying to suggest that we may do something better by adding a generic class/method to avoid this kind of duplication. Also if we sniff our codebase there might be many places where it can be improved. :)
Rebase on 5.0. |
Can I ask why? It's not a massive change or backwards compatibility break unless I've missed something. Really very minor change, there are bigger ones going into 4.3. |
You missed the part where you had to make amends in the login module for it not to crash. Extension developers must not be required to make changes in patch and minor versions. But you're right in that many more breaking changes have been introduced lately. It's almost as if the project does not follow SemVer anymore and screwing over Joomla users is the norm. So it's fine, another B/C break that bricks sites in a patch release is fine 🤡. |
Snark is unnecessary, it was a genuine question. Please be kind. I didn't make any changes to the login module. I made a very minor change to the menu module helper, which still works with data saved prior to this change. (Hence my test case 1.) Probably I could do it more elegantly as evidenced by the review comments, but I genuinely don't see how this is a breaking change when there is a check for the data type and it can handle both ways. |
This reverts commit 4c60638.
Co-authored-by: ReLater <ReLater@users.noreply.github.com>
Okay, so, I understand better now how the changes I suggested are a b/c break. Is there a way to approach this that would allow multiple rel values without the b/c break? Earlier in the process maybe, so that it gets turned to a string before any 3rd party component or plugin or template would call them? I thought the menu helper would be early enough, but I understand some people may bypass it. |
Copied from #39275 on request ReLater: crystalenka: ReLater:
to use
You would have a single location to change/add/(remove) new options. RelAttributesField.php could be a form field that extends ListField and thus would inherit all attributes of list field and behavior (multiple, layout etc.). Concerning B\C break: I have absolutely no idea if that is one. The idea with a new field. Was just an idea because I saw that you was correcting the options in 2 files. |
This pull request has been automatically rebased to 5.0-dev. |
This pull request has been automatically rebased to 5.1-dev. |
This pull request has been automatically rebased to 5.2-dev. |
Summary of Changes
According to MDN, the
rel
attribute on<link>
and<a>
elements can have multiple space-separated values.This PR makes this a little easier by turning the rel field into a fancy select list and allows multiple values, which get imploded into a string before getting passed back to the layout (so there shouldn't be B/C problems).
Testing Instructions
For this PR to be a success a few things must be true:
rel
fields must be converted over without loss of data.To test:
<a href="url here" rel="selected-attribute">
.)<a href="url here" rel="selected-attribute another-attr attribute-three">
.)Actual result BEFORE applying this Pull Request
Could not select multiple rel attributes.
Expected result AFTER applying this Pull Request
Existing links are unchanged; new capability of selecting multiple rel attributes works well.
Link to documentations
Please select:
Documentation link for docs.joomla.org:
No documentation changes for docs.joomla.org needed
Pull Request link for manual.joomla.org:
No documentation changes for manual.joomla.org needed
I don't know yet whether documentation is needed.