Monster/DOM

Monster/DOM

Author:
  • schukai GmbH

Classes

Assembler
CustomElement
Template
Theme
Updater

Members

# (static, constant) ATTRIBUTE_OPTIONS :string

Type:
  • string
Since:
  • 1.8.0

# (static, constant) ATTRIBUTE_PREFIX :string

Type:
  • string
Since:
  • 1.8.0

# (static, constant) ATTRIBUTE_THEME_NAME :string

Type:
  • string

# (static, constant) ATTRIBUTE_THEME_PREFIX :string

Type:
  • string
Since:
  • 1.8.0

# (static, constant) ATTRIBUTE_UPDATER_ATTRIBUTES :string

Type:
  • string
Since:
  • 1.8.0

# (static, constant) ATTRIBUTE_UPDATER_INSERT :string

Type:
  • string
Since:
  • 1.8.0

# (static, constant) ATTRIBUTE_UPDATER_INSERT_REFERENCE :string

Type:
  • string
Since:
  • 1.8.0

# (static, constant) ATTRIBUTE_UPDATER_REMOVE :string

Type:
  • string
Since:
  • 1.8.0

# (static, constant) ATTRIBUTE_UPDATER_REPLACE :string

Type:
  • string
Since:
  • 1.8.0

# (static, constant) ATTRIBUTEPREFIX :string

attribute prefix

Type:
  • string

# (static, constant) DEFAULT_THEME :string

default theme

Type:
  • string

Methods

# (static) findDocumentTemplate(id) → {Template}

you can call the method via the monster namespace Monster.DOM.findDocumentTemplate().

<script type="module">
import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.8.0/dist/modules/dom/template.js';
console.log(Monster.DOM.findDocumentTemplate())
</script>

Alternatively, you can also integrate this function individually.

<script type="module">
import {findTemplate} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.8.0/dist/modules/dom/template.js';
console.log(findDocumentTemplate())
</script>
Parameters:
Name Type Description
id string
Since:
  • 1.7.0
Throws:
  • template id not found.

    Type
    Error
  • value is not a string

    Type
    TypeError
Returns:
Type
Template

# (static) getDocument() → {object}

this method fetches the document object

<script type="module">
import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.8.0/dist/modules/dom/util.js';
console.log(Monster.DOM.getDocument())
</script>

Alternatively, you can also integrate this function individually.

<script type="module">
import {getDocument} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.8.0/dist/modules/dom/util.js';
console.log(getDocument())
</script>

in nodejs this functionality can be performed with jsdom.

import {JSDOM} from "jsdom"
if (typeof window !== "object") {
   const {window} = new JSDOM('', {
       url: 'http://example.com/',
       pretendToBeVisual: true
   });

   [
       'self',
       'document',
       'Document',
       'Node',
       'Element',
       'HTMLElement',
       'DocumentFragment',
       'DOMParser',
       'XMLSerializer',
       'NodeFilter',
       'InputEvent',
       'CustomEvent'
   ].forEach(key => (getGlobal()[key] = window[key]));
}
Since:
  • 1.6.0
Throws:

not supported environment

Type
Error
Returns:
Type
object

# (static) getDocumentFragmentFromString() → {DocumentFragment}

this method fetches the document object

<script type="module">
import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.8.0/dist/modules/dom/util.js';
console.log(Monster.DOM.getDocumentFragmentFromString())
</script>

Alternatively, you can also integrate this function individually.

<script type="module">
import {getDocumentFragmentFromString} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.8.0/dist/modules/dom/util.js';
console.log(getDocumentFragmentFromString('<div></div>'))
</script>

in nodejs this functionality can be performed with jsdom.

import {JSDOM} from "jsdom"
if (typeof window !== "object") {
   const {window} = new JSDOM('', {
       url: 'http://example.com/',
       pretendToBeVisual: true
   });

   [
       'self',
       'document',
       'Document',
       'Node',
       'Element',
       'HTMLElement',
       'DocumentFragment',
       'DOMParser',
       'XMLSerializer',
       'NodeFilter',
       'InputEvent',
       'CustomEvent'
   ].forEach(key => (getGlobal()[key] = window[key]));
}
Since:
  • 1.6.0
Throws:
  • not supported environment

    Type
    Error
  • value is not a string

    Type
    TypeError
Returns:
Type
DocumentFragment

# (static) getHandleFromNode(node) → {Handle|undefined}

get the handle of a node

if a node is specified without a handler, a recursive search upwards is performed until the corresponding handle is found, or undefined is returned.

you can call the method via the monster namespace Monster.DOM.getHandleFromNode().

<script type="module">
import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.8.0/dist/modules/dom/handle.js';
console.log(Monster.DOM.getHandleFromNode())
</script>

Alternatively, you can also integrate this function individually.

<script type="module">
import {getHandleFromNode} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.8.0/dist/modules/dom/handle.js';
console.log(getHandleFromNode())
</script>
Parameters:
Name Type Description
node Node
Since:
  • 1.6.0
Throws:

value is not an instance of Node

Type
TypeError
Returns:
Type
Handle | undefined

# (static) getWindow() → {object}

this method fetches the window object

<script type="module">
import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.8.0/dist/modules/dom/util.js';
console.log(Monster.DOM.getWindow())
</script>

Alternatively, you can also integrate this function individually.

<script type="module">
import {getWindow} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.8.0/dist/modules/dom/util.js';
console.log(getWindow(null))
</script>

in nodejs this functionality can be performed with jsdom.

import {JSDOM} from "jsdom"
if (typeof window !== "object") {
   const {window} = new JSDOM('', {
       url: 'http://example.com/',
       pretendToBeVisual: true
   });

   getGlobal()['window']=window;

   [
       'self',
       'document',
       'Document',
       'Node',
       'Element',
       'HTMLElement',
       'DocumentFragment',
       'DOMParser',
       'XMLSerializer',
       'NodeFilter',
       'InputEvent',
       'CustomEvent'
   ].forEach(key => (getGlobal()[key] = window[key]));
}
Since:
  • 1.6.0
Throws:

not supported environment

Type
Error
Returns:
Type
object

# (static) registerCustomElement(element) → {void}

This method registers a new element. The string returned by CustomElement.getTag() is used as the tag.

Parameters:
Name Type Description
element CustomElement
Since:
  • 1.7.0
Throws:

Failed to execute 'define' on 'CustomElementRegistry': is not a valid custom element name

Type
DOMException
Returns:
Type
void