jamietre / CsQuery

CsQuery is a complete CSS selector engine, HTML parser, and jQuery port for C# and .NET 4.
Other
1.15k stars 249 forks source link

Added category interfaces to BUTTON, INPUT, SELECT, LABEL, and SELECT. #138

Closed joelverhagen closed 10 years ago

joelverhagen commented 11 years ago

See the HTML 5 spec Forms page for more information. To determine in an element has an associated form, it is as easy as:

IDomElement e = doc["some selector"].FirstElement();
IFormAssociatedElement f = e as IFormAssociatedElement;

if(f != null)
    ...

Also:

jamietre commented 11 years ago

I would like to merge this, but don't have time to look at it carefully anytime soon, can you explain the purpose of the interfaces IFormSubmittableElement, IFormReassociatableElement? Are these just markers for convenience of end users?

joelverhagen commented 11 years ago

IFormSubmittableElement: this interface indicates that the element should be included in the data set generated when submitting the associated form.

IFormReassociatableElement: this interface indicates that the element can be associated with a non-ancestor form using the form attribute.

Yes, the interfaces themselves serve as convenience markers on elements. However, the associated abstract classes (FormSubmittableElement and FormReassociateableElement) do provide special functionality shared by all elements implementing this interface. You'll notice any element implementing these interfaces is doing so through inheritance of the associated abstract class.

In general, I hope these pull requests make working with form fields both more generic (e.g. only implement Disabled once for form fields) and more staticly typed (via the IHTML* interfaces).