Class: Token

(abstract) tokens/Token~Token()

Catch-all class for all token types.

Constructor

(abstract) new Token()

...

Methods

addAttribute(name, value)

Generic set attribute method.

Generic set attribute method.

Parameters:
Name Type Description
name string
value any
Source:

addNormalizedAttribute(name, value, origValue)

Generic set attribute method with support for change detection.

Generic set attribute method with support for change detection. Set a value and preserve the original wikitext that produced it.

Parameters:
Name Type Description
name string
value any
origValue any
Source:

addSpaceSeparatedAttribute(name, value)

Add a space-separated property value.

Add a space-separated property value.

Parameters:
Name Type Description
name string
value any

The value to add to the attribute.

Source:

getAttribute(name) → {any}

Generic attribute accessor.

Generic attribute accessor.

Parameters:
Name Type Description
name string
Source:
Returns:
Type
any

getAttributeShadowInfo(name) → {Object|any|boolean|boolean}

Attribute info accessor for the wikitext serializer.

Attribute info accessor for the wikitext serializer. Performs change detection and uses unnormalized attribute values if set. Expects the context to be set to a token.

Parameters:
Name Type Description
name string
Source:
Returns:
  • Information about the shadow info attached to this attribute.

    Type
    Object
  • return.value

    Type
    any
  • return.modified Whether the attribute was changed between parsing and now.

    Type
    boolean
  • return.fromsrc Whether we needed to get the source of the attribute to round-trip it.

    Type
    boolean

getWTSource(env) → {string}

Get the wikitext source of a token.

Get the wikitext source of a token.

Parameters:
Name Type Description
env MWParserEnvironment
Source:
Returns:
Type
string

removeAttribute(name)

Completely remove all attributes with this name.

Completely remove all attributes with this name.

Parameters:
Name Type Description
name string
Source:

setAttribute(name, value)

Set an unshadowed attribute.

Set an unshadowed attribute.

Parameters:
Name Type Description
name string
value any
Source:

setShadowInfo(name, value, origValue)

Store the original value of an attribute in a token's dataAttribs.

Store the original value of an attribute in a token's dataAttribs.

Parameters:
Name Type Description
name string
value any
origValue any
Source: