Class TagBuilder

TagBuilder class, used to build tags of course.

Hierarchy

  • ExFunc
    • TagBuilder

Constructors

Properties

_meta: TagMeta = ...
_parent: Tag
arguments: any
attr: AttrSet = ...

Do not modify directly, use helper methods in the tag instead.

caller: Function
children: ValidTagChild[] = []
length: number
name: string

Returns the name of the function. Function names are read-only and can not be changed.

prototype: any
tagName: TagName

Accessors

Methods

  • Determines whether the given value inherits from this function if this function was used as a constructor function.

    A constructor function can control which objects are recognized as its instances by 'instanceof' by overriding this method.

    Parameters

    • value: any

    Returns boolean

  • Parameters

    • Rest ...children: ValidTagChild[]

    Returns Tag

  • Shorthand for .addClass method. Adds classNames to this TagBuilder, and returns a new TagBuilder

    Parameters

    • Rest ...classNames: string[]

    Returns TagBuilder

  • Adds a single style, and returns a new TagBuilder

    Type Parameters

    • T extends CssProperty

    Parameters

    • key: T
    • value: PickPropertyValues<T>

    Returns TagBuilder

  • Adds tags as children if the tag can have children. For example, if tag is img there's no need to add the childre as they will not be generated.

    Parameters

    • Rest ...tags: ValidTagChild[]

    Returns TagBuilder

  • Calls the function, substituting the specified object for the this value of the function, and the specified array for the arguments of the function.

    Parameters

    • this: Function
    • thisArg: any

      The object to be used as the this object.

    • Optional argArray: any

      A set of arguments to be passed to the function.

    Returns any

  • Shorthand for .addStyle method Adds a single style, and returns a new TagBuilder

    Type Parameters

    • T extends CssProperty

    Parameters

    • key: T
    • value: PickPropertyValues<T>

    Returns TagBuilder

  • Shorthand for .build method Build the tag with additional children

    Parameters

    • Rest ...children: ValidTagChild[]

    Returns Tag

  • For a given function, creates a bound function that has the same body as the original function. The this object of the bound function is associated with the specified object, and has the specified initial parameters.

    Parameters

    • this: Function
    • thisArg: any

      An object to which the this keyword can refer inside the new function.

    • Rest ...argArray: any[]

      A list of arguments to be passed to the new function.

    Returns any

  • Build the tag with additional children

    Parameters

    • Rest ...children: ValidTagChild[]

    Returns Tag

  • Calls a method of an object, substituting another object for the current object.

    Parameters

    • this: Function
    • thisArg: any

      The object to be used as the current object.

    • Rest ...argArray: any[]

      A list of arguments to be passed to the method.

    Returns any

  • Parameters

    • tagName: TagName

    Returns TagMeta

  • Parameters

    • tagName: string

    Returns boolean

  • cm = modify calls fn with the tag, and returns the tag

    usefull to change a tag while maintaing chaning

    Parameters

    • fn: ((tag) => void)
        • (tag): void
        • Parameters

          Returns void

    Returns TagBuilder

    Example

    div().m(t => t.className.add("Container"))
    .div("I'm a child!"),

    Example

    div([
    p("Child1").m(t => t.className.add("child-1")),
    p("Child1").m(t => t.className.add("child-2"))
    ])
  • Shortcut for method .modClass

    Modifies the classnames of a tag. Similar to the .mod or .m methods but it passes the className instead of the complete tag.

    Retuns a new TagBuilder

    Parameters

    • arg0: ((c) => void)
        • (c): void
        • Parameters

          Returns void

    Returns TagBuilder

  • calls fn with the tag, and returns the tag

    usefull to change a tag while maintaing chaning

    Parameters

    • fn: ((tag) => void)
        • (tag): void
        • Parameters

          Returns void

    Returns TagBuilder

    Example

    div().m(t => t.className.add("Container"))
    .div("I'm a child!"),

    Example

    div([
    p("Child1").mod(t => t.className.add("child-1")),
    p("Child1").mod(t => t.className.add("child-2"))
    ])
  • Modifies the classnames of a tag. Similar to the .mod or .m methods but it passes the className instead of the complete tag.

    Retuns a new TagBuilder

    Parameters

    • arg0: ((c) => void)
        • (c): void
        • Parameters

          Returns void

    Returns TagBuilder

    Example

    div(
    p("Child1").modClass(c => c.add("child-1")),
    p("Child1").modClass(c => c.add("child-2"))
    )
  • Shorthand for .removeAttr method. Removes attribute from this TagBuilder, and returns a new TagBuilder

    Parameters

    • Rest ...attr: string[]

    Returns TagBuilder

  • Shorthand for .rmClass method. Removes classNames from this TagBuilder, and returns a new TagBuilder

    Parameters

    • Rest ...classNames: string[]

    Returns TagBuilder

  • Shorthand for .removeStyles method. Removes styles from this TagBuilder, and returns a new TagBuilder

    Parameters

    • Rest ...styleNames: string[]

    Returns TagBuilder

  • Shorthand for .setAttr method. Sets multiple atributes at once, and returns a new TagBuilder

    Parameters

    • attributes: {
          [key: string]: string;
      }
      • [key: string]: string

    Returns TagBuilder

  • Parameters

    • tagName: TagName

    Returns string

  • Sets multiple atributes at once, and returns a new TagBuilder

    Parameters

    • attributes: {
          [key: string]: string;
      }
      • [key: string]: string

    Returns TagBuilder

  • Returns a string representation of a function.

    Returns string

Generated using TypeDoc