Function node

  • Create a new DOM element, and insert it into the DOM at the position held by the current scope.

    Example

    node('aside.editorial', 'Yada yada yada....', () => {
    node('a', {href: '/bio'}, () => {
    node('img.author', {src: '/me.jpg', alt: 'The author'})
    })
    })

    Parameters

    • tag: string | Element = ""

      The tag of the element to be created and optionally dot-separated class names. For example: h1 or p.intro.has_avatar.

    • Rest ...rest: any[]

      The other arguments are flexible and interpreted based on their types:

      • string: Used as textContent for the element.
      • object: Used as attributes, properties or event listeners for the element. See Store.prop on how the distinction is made.
      • function: The render function used to draw the scope of the element. This function gets its own Scope, so that if any Store it reads changes, it will redraw by itself.
      • Store: Presuming tag is "input", "textarea" or "select", create a two-way binding between this Store value and the input element. The initial value of the input will be set to the initial value of the Store, or the other way around if the Store holds undefined. After that, the Store will be updated when the input changes and vice versa.

    Returns void

Generated using TypeDoc