feat: support data-smark-<option_name> attribute syntax for individual component options#86
Draft
feat: support data-smark-<option_name> attribute syntax for individual component options#86
data-smark-<option_name> attribute syntax for individual component options#86Conversation
…ions - Modified getNodeOptions() in component.js to read data-smark-<option_name> attributes as individual component options - Updated selector to also discover elements with data-smark-type or data-smark-action attributes (in addition to data-smark) - Attribute values are parsed as JSON (e.g. "true" → true, "42" → 42) with fallback to raw string - Throws DUPLICATE_OPTION error when same option is specified both in data-smark JSON and as data-smark-* attribute with different values - Same-value duplication is silently allowed (supports list template cloning) - Added 6 tests covering all aspects of the new feature Co-authored-by: bitifet <[email protected]>
Co-authored-by: bitifet <[email protected]>
Copilot
AI
changed the title
[WIP] Add support for data-smark attributes in component options
feat: support Feb 28, 2026
data-smark-<option_name> attribute syntax for individual component options
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
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.
Allows SmarkForm component options to be specified as individual HTML attributes (
data-smark-type="list") in addition to the existing JSON form (data-smark='{"type":"list"}'). Primary motivation: CSS targeting without needing manual class annotations.Changes
getNodeOptions()— after parsing the maindata-smarkJSON, scansnode.datasetfor entries matching{propertyName}{UppercaseLetter}…(e.g.smarkType,smarkName). Values are JSON-parsed with string fallback ("true"→true,"42"→42). ThrowsDUPLICATE_OPTIONif the same key appears in bothdata-smarkJSON and adata-smark-*attribute with different values; same-value duplication is silently accepted to support list-template clone normalization.me.selector— extended from[data-smark]to[data-smark],[data-smark-type],[data-smark-action]so elements that carry only individual attribute options (no baredata-smark) are discovered and enhanced.Notes
data-smark-export-empties→exportEmpties. Existing snake_case options likemin_itemscannot be targeted this way (data-smark-min-itemswould createminItems, notmin_items); usedata-smarkJSON for those.test/data_smark_attrs.tests.jscovers type/name resolution, JSON type coercion, DOM attribute persistence, list-item cloning, and theDUPLICATE_OPTIONerror path.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.