You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+61-7Lines changed: 61 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -373,6 +373,57 @@ Schemas validate the tag's flat attribute object. The tag name is implicit from
373
373
374
374
Attribute values are coerced by JSON Schema (`"2"` can satisfy an integer, valueless attributes become `true`). Attribute values containing mustache are treated as unknown runtime values, so value-dependent schema errors are waived while presence and unknown-attribute checks still run.
375
375
376
+
Custom tags can also declare parent-owned child schemas. Child schemas validate a direct child tag's flat attribute object only in the context of that parent:
`children.mode` defaults to `"strict"`, so the example above allows only direct `<pl-answer>` HTML elements under `<pl-multiple-choice>`. Set `"mode": "loose"` to keep unlisted direct child elements allowed while still schema-validating listed child tags when they appear. Mustache sections are transparent for this check: `<pl-answer>` inside `{{#cond}}...{{/cond}}` still counts as a direct child of the surrounding parent element.
399
+
400
+
Parent-owned child schemas do not create a global schema for the child tag. A bare `<pl-answer>` outside `<pl-multiple-choice>` is recognized by `{ "name": "pl-answer" }`, but it does not use the multiple-choice-specific child schema.
401
+
402
+
If a child tag is declared only inside `children.tags` and is not listed as a top-level `customTags` entry, it is recognized only as a child-owned tag and may appear only as a direct child of the parent tags that declared it. Listing the same tag at the top level means it can also appear in any other context.
403
+
404
+
`children.tags` can be nested recursively. Each level still validates only direct children, so this keeps `<pl-answer>` scoped to `<pl-multiple-choice>` while giving `<pl-answer>` its own allowed direct child tags:
@@ -395,13 +446,16 @@ Schemas must declare draft-06 using `http://json-schema.org/draft-06/schema#` (t
395
446
396
447
Schema diagnostics are phrased in HTML/element terms rather than JSON-Schema vocabulary, so template authors aren't asked to translate `instancePath` and `additionalProperty` back into the markup they wrote. Examples:
|`required: ["answers-name"]`|`<pl-multiple-choice> is missing required attribute "answers-name".`|
452
+
|`additionalProperties: false`|`Unknown attribute "extra" on <pl-multiple-choice>.`|
453
+
| strict unlisted child |`<pl-multiple-choice> only allows these child elements: <pl-answer>.`|
454
+
| child-only tag outside its parent |`<pl-answer> may only appear as a direct child of these parent elements: <pl-multiple-choice>.`|
455
+
| child `additionalProperties`|`Unknown attribute "ranking" on <pl-answer> inside <pl-multiple-choice>.`|
456
+
|`properties.display.enum`|`Attribute "display" on <pl-multiple-choice> must be one of: "block", "inline".`|
457
+
|`properties.size.type: "integer"`|`Attribute "size" on <pl-multiple-choice> must be integer.`|
458
+
|`properties.weight.minimum: 0`|`Attribute "weight" on <pl-multiple-choice> must be >= 0.`|
405
459
406
460
Constraints without a rewriter fall through to ajv's localized text. Every diagnostic carries `ruleName: "customTagSchema"` and points at the element or attribute — see [Disabling Lint Rules](#disabling-lint-rules) to silence them per-region.
0 commit comments