question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Validator: Disallow template tags on children of <div submit-success template=...> tags

See original GitHub issue

Related 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:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
honeybadgerdontcarecommented, Jan 4, 2018

Discussed in person, posting for posterity. Another alternative may be to widen the scope of disallowed_ancestor to also handle spec_name in addition to tag_name.

0reactions
honeybadgerdontcarecommented, Jan 29, 2018

This has been fixed and will be coming in a future validator release.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found