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

fix: colors and more, add igrnore change to savebutton #181 #180

parent 92bdb83c
No related branches found
No related tags found
No related merge requests found
......@@ -25,7 +25,7 @@ const attachedInternalSymbol = Symbol("attachedInternal");
* After defining a `CustomElement`, the `registerCustomElement` method must be called with the new class name. Only then
* will the tag defined via the `getTag` method be made known to the DOM.
*
* <img src="./images/customcontrol-class.png">
* <img src="./images/custom-control.png">
*
* This control uses `attachInternals()` to integrate the control into a form. If the target environment does not support
* this method, the [polyfill](https://www.npmjs.com/package/element-internals-polyfill) can be used.
......@@ -41,6 +41,12 @@ const attachedInternalSymbol = Symbol("attachedInternal");
*
* Read the HTML specification for Custom Element Reactions: {@link https://html.spec.whatwg.org/dev/custom-elements.html#custom-element-reactions|Custom Element Reactions}.
*
* @startuml custom-control.png
* skinparam monochrome true
* skinparam shadowing false
* HTMLElement <|-- CustomElement
* CustomElement <|-- CustomControl
* @enduml
* @summary A base class for custom controls based on CustomElement.
* @copyright schukai GmbH
* @license AGPLv3
......
......@@ -6,8 +6,14 @@
*/
import {Pathfinder} from "../../data/pathfinder.mjs";
import { isFunction } from "../../types/is.mjs";
import { attributeObserverSymbol } from "../customelement.mjs";
import {
isBoolean,
isString,
isObject,
isArray,
isFunction,
isInteger,
} from "../../types/is.mjs";
import {extractKeys} from "./extract-keys.mjs";
export {initOptionsFromAttributes};
......@@ -22,6 +28,7 @@ export { initOptionsFromAttributes };
* For example, the attribute 'data-monster-option-foo' maps to the 'bar' property in the options object.
*
* The mapping object would look like this:
*
* {
* 'foo': (value) => value + 'bar'
* // the value of the attribute 'data-monster-option-foo' is appended with 'bar'
......@@ -33,6 +40,8 @@ export { initOptionsFromAttributes };
* // e.g. <div data-monster-option-bar-baz="foo"></div>
* }
*
* Array values have to be separated by '::'.
*
* @since 3.38.0
* @param {HTMLElement} element - The DOM element to be used as the source of the attributes.
* @param {Object} options - The options object to be initialized.
......@@ -76,17 +85,21 @@ function initOptionsFromAttributes(
optionValue = value;
}
const typeOfOptionValue = typeof optionValue;
//const typeOfOptionValue = typeof optionValue;
if (optionValue === null || optionValue === undefined) {
value = null;
} else if (typeOfOptionValue === "boolean") {
} else if (isBoolean(optionValue)) {
value = value === "true";
} else if (typeOfOptionValue === "number") {
} else if (isInteger(optionValue)) {
value = Number(value);
} else if (typeOfOptionValue === "string") {
} else if (isString(optionValue)) {
value = String(value);
} else if (typeOfOptionValue === "object") {
} else if (isObject(optionValue)) {
value = JSON.parse(value);
} else if (isArray(optionValue)) {
value = value.split("::");
} else {
value = optionValue;
}
finder.setVia(optionName, value);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment