Skip to content

I2I: AMP Form Dirtiness Indicator Class #22534

@xrav3nz

Description

@xrav3nz

Summary

This proposes a new amp-form-dirty class, that will be applied to AMP form’s <form> element, when any of its containing form controls is dirty.

This allows AMP document developers to style forms differently when it has been modified by the user, and there are unsubmitted data.

Design Document

https://docs.google.com/document/d/16Q3yY-XRtCVjlcsRYkrXYlmZJfcIrFgnMKqXsy3nS4w

Attack Plan

  • Export isDisabled helper
  • Extract an isFieldDefault helper from current isDirty_ implementation
  • An isFieldEmpty helper that checks if a field is empty
  • Track text-type inputs and textarea's dirtiness, based on default value and emptiness
  • Track radio button, checkbox, and dropdown menu's dirtiness, based on default value and emptiness
  • Track submitted form data
  • Track amp-bind form values changes

Potential Future Improvements

  • Support custom AMP components (e.g. <amp-selector>)
  • Track some attribute changes (disabled and hidden) with a Mutation Observer

/cc @cvializ @GoTcWang @zhangsu

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions