Validator: Disallow template tags on children of <div submit-success template=...> tags
See original GitHub issueRelated to https://github.com/ampproject/amphtml/pull/12593
We would like to implement a validator rule that allows:
<div submit-success>
<template>...</template>
</div>
But which disallows:
<div submit-success template=...>
<template>...</template>
</div>
That is, if the <div submit-success>
tag also has a template
attribute, then we do not allow any of it’s child tags to be a template tag.
Currently, there is no good way to do this with the validator rule system. My proposed rule type would look like:
tags {
tag_name: "DIV"
spec_name: "FORM > DIV [submit-success]"
attrs: {
name: "submit-success"
mandatory: true
dispatch_key: NAME_DISPATCH
}
}
tags {
tag_name: "DIV"
spec_name: "FORM > DIV [submit-success][template]"
attrs: {
name: "submit-success"
mandatory: true
}
attrs: {
name: "template"
mandatory: true
dispatch_key: NAME_DISPATCH
}
}
tags: {
tag_name: "TEMPLATE"
disallowed_ancestor_tagspec: "FORM > DIV [submit-success][template]"
...
}
When the validator encounters a <div submit-success>
tag, it will record which tagspec was found to match in the tag stack. When it encounters the <template>
tag later, it will pass/fail based on which tagspec is recorded in the tag stack.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:5 (5 by maintainers)
Top Results From Across the Web
The attribute 'submit-success' may not appear in tag 'div' #16500
I can't find any documented reason for not adding the ability to put form templates outside of the first-child level of the form....
Read more >HTML - where can I put the <template> tag without the W3C ...
The <template> tag currently has the status of an editors draft. That means it is not part of the W3C standard yet, so...
Read more >How to fix: Element “div” not allowed as child of element “ul” in ...
A <div> tag has been found as a direct child of an <ul> tag, and this is not allowed. For example, <ul><div><li>item</li></div></ul> is...
Read more >Form - Ant Design
High performance Form component with data scope management. ... Basic Form data control. Includes layout, initial values, validation and submit. expand code.
Read more >Example: <amp-form> - amp.dev
The amp-form extension allows the usage of forms and input fields in an ... The submit-success and submit-error elements must be direct children...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Discussed in person, posting for posterity. Another alternative may be to widen the scope of
disallowed_ancestor
to also handlespec_name
in addition totag_name
.This has been fixed and will be coming in a future validator release.