Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Monster
Manage
Activity
Members
Plan
Jira
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OSS
Libraries
Javascript
Monster
Commits
79c2c6e8
Verified
Commit
79c2c6e8
authored
1 year ago
by
Volker Schukai
Browse files
Options
Downloads
Patches
Plain Diff
feat: new updaterTransformerMethodsSymbol method #163
parent
23491368
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
source/dom/customelement.mjs
+911
-864
911 additions, 864 deletions
source/dom/customelement.mjs
with
911 additions
and
864 deletions
source/dom/customelement.mjs
+
911
−
864
View file @
79c2c6e8
...
...
@@ -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
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment