Skip to content
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

Enhanced to support targeting inner elements #11

Merged

Conversation

zackpyle
Copy link
Collaborator

@zackpyle zackpyle commented Jul 17, 2024

Added the ability to add custom attributes to specific inner child elements within a module's, column's, or row's wrapper.

Changes Made:

Form:

  • Added a new field target in the custom attributes form to specify the CSS selector for the target inner element.

Custom Attribute Handling:

  • Modified the filterAttributes function to handle attributes with and without target selectors.
  • Attributes with target selectors are stored in the data-custom-attributes attribute as a JSON string.
  • Attributes without target selectors are added directly to the wrapper element as before

JavaScript:

  • Enqueued a script using the DOMContentLoaded event to process custom attributes as soon as the DOM is fully loaded.
  • Reads the data-custom-attributes attribute, if present.
  • Parses the JSON string to get the list of custom attributes.
  • Applies the custom attributes to the specified target elements within the wrapper.
  • Removes the data-custom-attributes attribute from the wrapper element after processing.

Added the ability to add custom attributes to specific inner child elements within a module's, column's, or row's wrapper.

Changes Made:

Form:
- Added a new field target in the custom attributes form to specify the CSS selector for the target inner element.

Custom Attribute Handling:
- Modified the filterAttributes function to handle attributes with and without target selectors.
- Attributes with target selectors are stored in the data-custom-attributes attribute as a JSON string.
- Attributes without target selectors are added directly to the wrapper element as before

JavaScript:
-Enqueued a script using the DOMContentLoaded event to process custom attributes as soon as the DOM is fully loaded.
- Reads the data-custom-attributes attribute, if present.
- Parses the JSON string to get the list of custom attributes.
- Applies the custom attributes to the specified target elements within the wrapper.
- Removes the data-custom-attributes attribute from the wrapper element after processing.
Copy link
Owner

@JasonTheAdams JasonTheAdams left a comment

Choose a reason for hiding this comment

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

Sadly, I don't have time to test this (so please do), but I like the idea and the code looks good!

@zackpyle
Copy link
Collaborator Author

Great! I have tested it on my own site and works well. I will have someone else test to confirm it doesn't "only work on my setup"

@zackpyle zackpyle merged commit dba2a25 into JasonTheAdams:master Jul 22, 2024
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.

2 participants