Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mojavelinux opened this issue Aug 14, 2015 · 2 comments

Comments

@mojavelinux
Copy link

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.

@mojavelinux
Copy link
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.

@mojavelinux mojavelinux changed the title Check for readOnly property instead of specific element names Check for form elements by property instead of specific element names Aug 14, 2015
@mojavelinux
Copy link
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant