-
-
Notifications
You must be signed in to change notification settings - Fork 810
Allow ADD_ATTR and ADD_TAGS to accept a function #1150
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Allow ADD_ATTR configuration option to receive a function with signature (attributeName: string, tagName: string) => boolean, enabling granular control over which attributes are allowed for specific elements.
Allow ADD_TAGS configuration option to receive a function with signature (tagName: string) => boolean, enabling granular control over which tags are allowed.
cure53
approved these changes
Oct 5, 2025
|
Amazing, thank you very much! ❤️ |
|
Thanks for accepting this. I already have a case where I'd like to use this feature. Will you be cutting another release anytime soon? |
|
I say thanks 🙂 And yes, maybe this week, latest next week. |
cure53
added a commit
that referenced
this pull request
Oct 13, 2025
* Update README.md * Update README.md * Update README.md * fix: Removed slot as SVG element, leaving it for HTML, see #1174 * feat: allow ADD_ATTR to accept a function Allow ADD_ATTR configuration option to receive a function with signature (attributeName: string, tagName: string) => boolean, enabling granular control over which attributes are allowed for specific elements. * feat: allow ADD_TAGS to accept a function Allow ADD_TAGS configuration option to receive a function with signature (tagName: string) => boolean, enabling granular control over which tags are allowed. * Allow ADD_ATTR and ADD_TAGS to accept a function (#1150) * feat: allow ADD_ATTR to accept a function Allow ADD_ATTR configuration option to receive a function with signature (attributeName: string, tagName: string) => boolean, enabling granular control over which attributes are allowed for specific elements. * feat: allow ADD_TAGS to accept a function Allow ADD_TAGS configuration option to receive a function with signature (tagName: string) => boolean, enabling granular control over which tags are allowed. * Update README.md (#1151) * feat: add "mask-type" SVG attribute (resolves #1154) (#1155) * chore: Preparing 3.3.0 release --------- Co-authored-by: Drew Neil <[email protected]> Co-authored-by: Prasad Rajandran <[email protected]>
cure53
added a commit
that referenced
this pull request
Oct 13, 2025
* Update README.md * Update README.md * Update README.md * fix: Removed slot as SVG element, leaving it for HTML, see #1174 * feat: allow ADD_ATTR to accept a function Allow ADD_ATTR configuration option to receive a function with signature (attributeName: string, tagName: string) => boolean, enabling granular control over which attributes are allowed for specific elements. * feat: allow ADD_TAGS to accept a function Allow ADD_TAGS configuration option to receive a function with signature (tagName: string) => boolean, enabling granular control over which tags are allowed. * Allow ADD_ATTR and ADD_TAGS to accept a function (#1150) * feat: allow ADD_ATTR to accept a function Allow ADD_ATTR configuration option to receive a function with signature (attributeName: string, tagName: string) => boolean, enabling granular control over which attributes are allowed for specific elements. * feat: allow ADD_TAGS to accept a function Allow ADD_TAGS configuration option to receive a function with signature (tagName: string) => boolean, enabling granular control over which tags are allowed. * Update README.md (#1151) * feat: add "mask-type" SVG attribute (resolves #1154) (#1155) * chore: Preparing 3.3.0 release --------- Co-authored-by: Drew Neil <[email protected]> Co-authored-by: Prasad Rajandran <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This PR addresses issue #1149 by allowing
ADD_ATTRto accept a function for tag-specific attribute validation.Background & Context
Currently,
ADD_ATTRonly accepts a string array, creating a flat list of allowed attributes that applies to all tags. This limitation means you cannot specify that certain attributes should only be allowed on specific tags without writing custom hooks.Tasks
First Commit: Extends
ADD_ATTRto accept either a string array (for backwards compatibility) or a function with signature(attributeName: string, tagName: string) => boolean. When a function is provided, it enables granular control over which attributes are allowed for specific tags.Second Commit: Extends the same pattern to
ADD_TAGS, allowing it to accept a function with signature(tagName: string) => booleanfor consistency. If you prefer to keep the scope limited to the original issue, I'm happy to drop this commit or squash both together.Dependencies
n/a