Skip to content
Snippets Groups Projects
Verified Commit 79c2c6e8 authored by Volker Schukai's avatar Volker Schukai :alien:
Browse files

feat: new updaterTransformerMethodsSymbol method #163

parent 23491368
No related branches found
No related tags found
No related merge requests found
......@@ -62,6 +62,7 @@ export {
attributeObserverSymbol,
registerCustomElement,
getSlottedElements,
updaterTransformerMethodsSymbol
};
/**
......@@ -78,6 +79,14 @@ const assembleMethodSymbol = Symbol.for(
"@schukai/monster/dom/@@assembleMethodSymbol",
);
/**
* @memberOf Monster.DOM
* @type {symbol}
*/
const updaterTransformerMethodsSymbol = Symbol.for(
"@schukai/monster/dom/@@updaterTransformerMethodsSymbol",
);
/**
* this symbol holds the attribute observer callbacks. The key is the attribute name.
* @memberOf Monster.DOM
......@@ -478,7 +487,8 @@ class CustomElement extends HTMLElement {
value = new Pathfinder(
this[internalSymbol].getRealSubject()["options"],
).getVia(path);
} catch (e) {}
} catch (e) {
}
if (value === undefined) return defaultValue;
return value;
......@@ -527,6 +537,39 @@ class CustomElement extends HTMLElement {
return this;
}
/**
* This method is called once when the object is equipped with update for the dynamic change of the dom.
* The functions returned here can be used as pipe functions in the template.
*
* In the example, the function `my-transformer` is defined. In the template you can use it as follows:
*
* ```html
* <my-element data-monster-option-transformer="path:my-value | call:my-transformer"></my-element>
* ```
*
* @example
* [updaterTransformerMethodsSymbol]() {
* return {
* "my-transformer": (value) => {
* switch (typeof Wert) {
* case "string":
* return value + "!";
* case "Zahl":
* return value + 1;
* default:
* return value;
* }
* }
* };
* };
*
* @return {object}
* @since 2.43.0
*/
[updaterTransformerMethodsSymbol]() {
return {};
}
/**
* This method is called once when the object is included in the DOM for the first time. It performs the following actions:
* 1. Extracts the options from the attributes and the script tag of the element and sets them.
......@@ -604,6 +647,7 @@ class CustomElement extends HTMLElement {
return this;
}
/**
* You know what you are doing? This function is only for advanced users.
* The result is a clone of the internal data.
......@@ -636,7 +680,8 @@ class CustomElement extends HTMLElement {
* @return {void}
* @since 1.7.0
*/
disconnectedCallback() {}
disconnectedCallback() {
}
/**
* The custom element has been moved into a new document (e.g. someone called document.adoptNode(el)).
......@@ -644,7 +689,8 @@ class CustomElement extends HTMLElement {
* @return {void}
* @since 1.7.0
*/
adoptedCallback() {}
adoptedCallback() {
}
/**
* Called when an observed attribute has been added, removed, updated, or replaced. Also called for initial
......@@ -1017,7 +1063,8 @@ function parseOptionsJSON(data) {
try {
const dataUrl = parseDataURL(data);
data = dataUrl.content;
} catch (e) {}
} catch (e) {
}
try {
obj = JSON.parse(data);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment