Monster/DOM

Monster/DOM

Source:
Author:
  • schukai GmbH

Classes

Assembler
Template

Members

(static, constant) ATTRIBUTEPREFIX :string

Source:

attribute prefix

Type:
  • string

Methods

(static) getDocument() → {object}

Source:
Since:
  • 1.6.0

this method fetches the document object

<script type="module">
import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.6.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.6.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]));
}
Throws:

not supported environment

Type
Error
Returns:
Type
object

(static) getDocumentFragmentFromString() → {DocumentFragment}

Source:
Since:
  • 1.6.0

this method fetches the document object

<script type="module">
import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.6.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.6.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]));
}
Throws:
  • not supported environment

    Type
    Error
  • value is not a string

    Type
    TypeError
Returns:
Type
DocumentFragment

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

Source:
Since:
  • 1.6.0

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.6.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.6.0/dist/modules/dom/handle.js';
console.log(getHandleFromNode())
</script>
Parameters:
Name Type Description
node Node
Throws:

value is not an instance of Node

Type
TypeError
Returns:
Type
Handle | undefined

(static) getWindow() → {object}

Source:
Since:
  • 1.6.0

this method fetches the window object

<script type="module">
import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.6.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.6.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]));
}
Throws:

not supported environment

Type
Error
Returns:
Type
object