Announcement

Collapse
No announcement yet.

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

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

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

    See deck.net link below

    https://deck.net/5f410cd5693f6f7e11cf769056d1cbf9
    (additional question : how to use Bridge.Html5 in deck.net ? 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 ?

    #2
    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
    {
        [Bridge.Template("document.createElement(\"option\")")]
        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
    https://deck.net/9b479671baeef5dfe8f69d740612f45f

    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
    https://deck.net/303611cbf7bf1b92ffa7b457c7e57504

    Comment

    Working...
    X