scrapy / cssselect

CSS Selectors for Python
https://cssselect.readthedocs.io/
Other
290 stars 61 forks source link

HTML :enable and :disabled are not quite conformant #6

Open SimonSapin opened 12 years ago

SimonSapin commented 12 years ago

These should match :enabled, but currently do not:

li elements that are children of menu elements, and that have a child element that defines a command, if the first such element's Disabled State facet is false (not disabled)

(Similarly for :disabled with Disabled State facet is true (disabled))

Form elements should be considered disabled

... if its disabled attribute is set, or if it is a descendant of a fieldset element whose disabled attribute is set and is not a descendant of that fieldset element's first legend element child, if any.

The last part was skipped, so the current implementation is:

... if its disabled attribute is set, or if it is a descendant of a fieldset element whose disabled attribute is set

Gallaecio commented 5 years ago

Those links are currently broken. They are available in the wayback machine, though:

None of the specifications linked from the Mozilla documentation mention these cases.

Moreover, the two linked specifications which do detail what should be considered :enabled or :disabled, which are the HTML5 specification and the HTML Living Standard, seem to provide a definition that is simpler than our current implementation.

@redapple, @kmike, @dangra What should we do? Should we follow the living standard? Should we follow the HTML5 standard? Should we make it possible to select which standard to follow?

blaise-io commented 5 years ago

I just ran into an issue related to this.

I was expecting <input type="hidden"> to match input:enabled, but it didn't match because of https://github.com/scrapy/cssselect/blob/cb7a7e21de1ba9347d58a6a14b7c78b3de1f49ca/cssselect/xpath.py#L755

cssselect's implementation does not match the spec and it also does not match the implementation in Chrome and Firefox where input:enabled does match the hidden input element.