Skip to content

HTML DOM Representation #42

Description

@DavePearce

(@altmattr --- this may also be of interest to you)

My initial efforts to represent the DOM in Whiley have provided some interesting observations. Firstly, we need some way to interact natively with the DOM (see #41). Secondly, the DOM has an inbuilt concept of a union type. For example, here is an abridged version of the Node interface:

public type Node is &{
    int nodeType,
    js_string nodeName,
    (null | Element) parent,
    Node[] childNodes,
    ...
}

From this, we can see two interesting things: js_string and null | Element.

Both of these pose interesting questions. At this stage, I've just modelled a js_string using an int because this give me a sensible (if not slightly broken) translation. Likewise, at this stage, the union type null | Element is modelled correctly because we are not using tagged unions. However, as soon as we employ tagged unions (which is my current plan) this will break.

Perhaps one other interesting thing is that there is a clear notion of inheritance between the Node interface and the Element interface. Currently, Whiley provides no support for capturing this.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions