Skip to content

Conversation

@draganescu
Copy link
Contributor

Description

Closes #16636

How has this been tested?

Tested locally.

Screenshots

Types of changes

Added two functions that handle the rel and target attributes accordingly. I used classnames as a tokenizer for lack of a better option, but I believe classnames works for rel just as well as for class.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.

"destination": {
"type": "string"
},
"rel": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems the (block) attribute rel can be computed from the attributes opensInNewTab and nofollow. If that's the case can we remove the rel attribute, and on the save function depending on the attributes opensInNewTab and nofollow we save the current value for the rel (HTML attribute)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but why? Isn't rel an attribute anyway? Is there a reason to have less attributes, especially when we are actually printing attributes on render?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason is that each time we update the original attribute we also need to update the derived attribute forgetting to do that introduces bugs. In the future, one may easily add a logic that changes nofollow attribute and forgets to change the rel attribute. Another reason is that saving an attribute that can be computed adds more information in the database without a need.

@draganescu
Copy link
Contributor Author

Closing, to be treated in a wider perspective.

@draganescu draganescu closed this Sep 24, 2019
@youknowriad youknowriad deleted the fix/menu-item-open-in-new-tab branch May 27, 2020 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Open page in new tab option

3 participants