No announcement yet.

[CLOSED] HTMLOptionElement - From Bridge.Html5 to Retyped.dom

  • Filter
  • Time
  • Show
Clear All
new posts

    [CLOSED] HTMLOptionElement - From Bridge.Html5 to Retyped.dom

    See link below
    (additional question : how to use Bridge.Html5 in ? Is it still available ?)

    When using Saltarelle and then Bridge.Html5, this code :

    Bridge.Html5.Element option1 = Bridge.Html5.Document.CreateElement("option");
    Would provide a HTMLOptionElement.

    But this code (Retyped) :

    Retyped.dom.Element option2 = new Document().createElement("option");
    Will provide a Element.

    I then have a plugin (jquery multiselect), that read the "options" to get the value.

    If the element is an "Element", element.value does not exist.
    If it is a HTMLOptionElement, element.value do exist.

    Any hint ?
    Do the problem come from the previous implementation (Bridge.Html5) or the current one (Retyped.dom) ?
    Should I do it in another way ?

    Hi sacha,

    The reason why you got Element type is because createElement(string el) is a common function for creating any HTML element, so a base class was returned that could be casted to a required type. I suggest using constructors as the most simple way of creating elements. Both Retyped.dom and Bridge.Html5 contain proper [Template] attributes invoking createElement(string el) function.

    public sealed class HTMLOptionElement : HTMLElement
        public extern HTMLOptionElement();
        // ..
    Below are 2 samples, one is written using Retyped.dom, and the other using Bridge.Html5. They're actually almost identical except name casing: Retyped.dom uses the original API lowerCase, and Bridge.Html5 uses PascalCase.

    1. Retyped.dom

    option3 is created using "enum" of element types. It also requires casting now, but we'll likely be able to get rid of that soon.

    2. Bridge.Html5