Skip to content

Conversation

andreastt
Copy link
Member

We should not coerce values of boolean attributes as this is the job for
getting an element’s property. The use case for this is wanting to get
"foo" from <input disabled="foo">.

The patch also addresses getting the attribute of web element's element.

<a href=https://dom.spec.whatwg.org/#concept-element-attributes-get-by-name>getting an attribute</a>
given <var>name</var> and <var>element</var>.

<li><p>Let <var>result</var> be the value of <var>attribute</var>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think just returning the value here is good because <input disabled> is just going to return "" where I really think that they want the result of hasAttribute. Since boolean attributes don't actually need values. Most best practises recommend that people do hasAttribute for booleans I would rather have that as the result.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That’s what calling getAttribute on a DOM element is supposed to return. Having special WebDriver behaviour for this means you wouldn’t be able to return "incorrect" from <input disabled=incorrect>, and would deviate from DOM.

If you want to check if an element is disabled we should be encouraging the use of Get Element Property. The concept of coerced boolean attributes is what the browser needs to determine if the input attribute is valid or not, in order to set the element’s disabled property.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With Web Components there is no reflection between attributes and properties here so people will want to known if the attribute is disabled or not.

I am ok with conflating getAttribute and hasAttribute in this call.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m not really sure what you’re proposing here. That Get Element Attribute duplicate the behaviour of Get Element Property specifically when interacting with form control elements? All elements?

I think my primary counterargument is that attributes is a DOM concept, and the DOM doesn’t say anything about disabledness/checkedness of HTML elements. I don’t think it’s a particularly good idea if we rocked this idea, despite that HTML reflects changes to the property to the DOM.

Since it’s HTML that defines the disabled concept, what users want also isn’t hasAttribute("disabeld"), although in the particular case of calling that on form control elements it would effectively give you the same result.

I think making the change I think you’re suggesting would lead to a situation where WebDriver has a special definition of what it means to be a content attribute, different to that of DOM and HTML. It would effectively mean that if users actually wanted the actual, correct value of the content attribute, they’d have to call Execute Script, asking for arguments[0].getAttribute("disabled"), which yet again proves why we shouldn’t overload the “attribute” concept. It’s hard enough to explain what Get Element Attribute does in Selenium WebDriver as it is.

I’d rather we keep the primitives close to existing web platform technologies instead of inventing our own behaviour and especially overload existing terminology. If local ends wish to implement a behaviour that diverges from the web platform, they are able to do so with the primitives we provide them with.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per my comment on the Wires bug, I don't actually see how to implement the currently specified behaviour without a list of boolean attributes in the implementation. That's because it isn't possible to tell whether a specific content attribute is actually a boolean attribute through DOM APIs.

@andreastt
Copy link
Member Author

@AutomatedTester r?

We should not coerce values of boolean attributes as this is the job for
getting an element’s property.  The use case for this is wanting to get
"foo" from <input disabled="foo">.

The patch also addresses getting the attribute of web element's element.
@andreastt
Copy link
Member Author

Rebased again.

@AutomatedTester
Copy link
Contributor

I have spoke to @andreastt about this and think that this will be a good point to discuss at TPAC. Leaving open for now.

@AutomatedTester
Copy link
Contributor

this was decided to remain as is

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

Successfully merging this pull request may close these issues.

3 participants