Skip to content

Check for form elements by property instead of specific element names #1

Open

Description

@mojavelinux

Check for an input name based on whether it has the property "readOnly" and the value is false instead of checking for element names. It's both faster and more accurate.

Activity

  1. mojavelinux commented on Aug 14, 2015

    @mojavelinux
    Author

    Actually, it seems like the most accurate way to detect a form element is to check if it has the "disabled" property (disregarding the value as disabled elements can't receive events).

    That leaves us with:

    ('disabled' in element) || element.contentEditable === 'true'

    Originally I was going to check for a readOnly element, but Firefox lets you move the cursor around in a readOnly element, so that seems useful to preserve.

  2. changed the title [-]Check for readOnly property instead of specific element names[/-] [+]Check for form elements by property instead of specific element names[/+] on Aug 14, 2015
  3. mojavelinux commented on Aug 14, 2015

    @mojavelinux
    Author

    To clarify, select elements don't have the readOnly property (if you can't believe it) which is why we can't use it. Clearly we can't agree on a single definition of read only in HTML :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions