Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
Loading items

Target

Select target project
  • oss/libraries/javascript/monster
1 result
Select Git revision
Loading items
Show changes

Commits on Source 9

Showing
with 334 additions and 153 deletions
<a name="v3.46.0"></a>
## [v3.46.0] - 2023-05-02
### Bug Fixes
- tests
### Changes
- update packages
### Code Refactoring
- attribute and form improvments
<a name="v3.44.1"></a>
## [v3.44.1] - 2023-05-01
### Bug Fixes
......@@ -602,6 +614,7 @@
<a name="1.8.0"></a>
## 1.8.0 - 2021-08-15
[v3.46.0]: https://gitlab.schukai.com/oss/libraries/javascript/monster/compare/v3.44.1...v3.46.0
[v3.44.1]: https://gitlab.schukai.com/oss/libraries/javascript/monster/compare/v3.44.0...v3.44.1
[v3.44.0]: https://gitlab.schukai.com/oss/libraries/javascript/monster/compare/v3.43.0...v3.44.0
[v3.43.0]: https://gitlab.schukai.com/oss/libraries/javascript/monster/compare/v3.42.1...v3.43.0
......
{
"name": "@schukai/monster",
"version": "3.44.0",
"version": "3.44.1",
"description": "Monster is a simple library for creating fast, robust and lightweight websites.",
"keywords": [
"framework",
......
......@@ -9,6 +9,7 @@ import { extend } from "../data/extend.mjs";
import {ATTRIBUTE_VALUE} from "./constants.mjs";
import {CustomElement, attributeObserverSymbol} from "./customelement.mjs";
import {instanceSymbol} from "../constants.mjs";
export {CustomControl};
/**
......@@ -41,6 +42,7 @@ const attachedInternalSymbol = Symbol("attachedInternal");
* @see {@link https://www.npmjs.com/package/element-internals-polyfill}
* @see {@link https://github.com/WICG/webcomponents}
* @see {@link https://html.spec.whatwg.org/multipage/custom-elements.html#custom-elements}
* @see {@link https://html.spec.whatwg.org/dev/custom-elements.html#custom-element-reactions}
* @license AGPLv3
* @since 1.14.0
* @copyright schukai GmbH
......@@ -74,7 +76,7 @@ class CustomControl extends CustomElement {
* @since 2.1.0
*/
static get [instanceSymbol]() {
return Symbol.for("@schukai/monster/dom/custom-control");
return Symbol.for("@schukai/monster/dom/custom-control@@instance");
}
/**
......@@ -84,20 +86,18 @@ class CustomControl extends CustomElement {
* @since 1.15.0
*/
static get observedAttributes() {
const list = super.observedAttributes;
list.push(ATTRIBUTE_VALUE);
return list;
return super.observedAttributes;
}
/**
* Adding a static formAssociated property, with a true value, makes an autonomous custom element a form-associated custom element.
*
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/attachInternals}
* @see {@link https://html.spec.whatwg.org/multipage/custom-elements.html#custom-elements-face-example}
* @since 1.14.0
* @return {boolean}
*/
static get formAssociated() {
return true;
}
static formAssociated = true
/**
* Derived classes can override and extend this method as follows.
......@@ -116,7 +116,8 @@ class CustomControl extends CustomElement {
* @since 1.14.0
*/
get defaults() {
return extend({}, super.defaults);
return extend({
}, super.defaults);
}
/**
......@@ -298,6 +299,46 @@ class CustomControl extends CustomElement {
reportValidity() {
return getInternal.call(this)?.reportValidity();
}
/**
* @param {string} form
*/
formAssociatedCallback(form) {
if (form) {
if(form.id) {
this.setAttribute("form", form.id);
}
} else {
this.removeAttribute("form");
}
}
/**
* @param {string} disabled
*/
formDisabledCallback(disabled) {
if (disabled) {
this.setAttribute("disabled", "");
} else {
this.removeAttribute("disabled");
}
}
/**
* @param {string} state
* @param {string} mode
*/
formStateRestoreCallback(state, mode) {
}
/**
*
*/
formResetCallback() {
this.value = "";
}
}
/**
......@@ -313,7 +354,7 @@ function getInternal() {
throw new Error("ElementInternals is not supported and a polyfill is necessary");
}
return this[attachedInternalSymbol];
return self[attachedInternalSymbol];
}
/**
......
......@@ -31,6 +31,7 @@ import {instanceSymbol} from "../constants.mjs";
import {getDocumentTranslations, Translations} from "../i18n/translations.mjs";
import {getSlottedElements} from "./slotted.mjs";
import {initOptionsFromAttributes} from "./util/init-options-from-attributes.mjs";
import {setOptionFromAttribute} from "./util/set-option-from-attribute.mjs";
export {
CustomElement,
......@@ -220,7 +221,7 @@ class CustomElement extends HTMLElement {
* @since 2.1.0
*/
static get [instanceSymbol]() {
return Symbol.for("@schukai/monster/dom/custom-element");
return Symbol.for("@schukai/monster/dom/custom-element@@instance");
}
/**
......@@ -232,7 +233,7 @@ class CustomElement extends HTMLElement {
* @since 1.15.0
*/
static get observedAttributes() {
return [ATTRIBUTE_OPTIONS, ATTRIBUTE_DISABLED];
return [];
}
/**
......@@ -309,7 +310,7 @@ class CustomElement extends HTMLElement {
*/
get defaults() {
return {
ATTRIBUTE_DISABLED: this.getAttribute(ATTRIBUTE_DISABLED),
disabled: false,
shadowMode: "open",
delegatesFocus: true,
templates: {
......@@ -605,8 +606,11 @@ class CustomElement extends HTMLElement {
attributeChangedCallback(attrName, oldVal, newVal) {
const self = this;
const callback = self[attributeObserverSymbol]?.[attrName];
if (attrName.startsWith("data-monster-option-")) {
setOptionFromAttribute(self, attrName, this[internalSymbol].getSubject()["options"])
}
const callback = self[attributeObserverSymbol]?.[attrName];
if (isFunction(callback)) {
try {
callback.call(self, newVal, oldVal);
......
/**
* Copyright schukai GmbH and contributors 2023. All Rights Reserved.
* Node module: @schukai/monster
* This file is licensed under the AGPLv3 License.
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
*/
export {extractKeys}
/**
* Extracts the keys from the given object and returns a map with the keys and values.
*
* @private
* @param {object} obj
* @param {string} keyPrefix
* @param {string} keySeparator
* @param {string} valueSeparator
* @returns {Map<any, any>}
*/
function extractKeys(obj, keyPrefix = '', keySeparator = '-', valueSeparator = '.') {
const resultMap = new Map();
function helper(currentObj, currentKeyPrefix, currentValuePrefix) {
for (const key in currentObj) {
if (typeof currentObj[key] === 'object' && !Array.isArray(currentObj[key])) {
const newKeyPrefix = currentKeyPrefix ? currentKeyPrefix + keySeparator + key.toLowerCase() : key.toLowerCase();
const newValuePrefix = currentValuePrefix ? currentValuePrefix + valueSeparator + key : key;
helper(currentObj[key], newKeyPrefix, newValuePrefix);
} else {
const finalKey = currentKeyPrefix ? currentKeyPrefix + keySeparator + key.toLowerCase() : key.toLowerCase();
const finalValue = currentValuePrefix ? currentValuePrefix + valueSeparator + key : key;
resultMap.set(finalKey, finalValue);
}
}
}
helper(obj, keyPrefix, keyPrefix);
return resultMap;
}
\ No newline at end of file
......@@ -8,6 +8,7 @@
import {Pathfinder} from '../../data/pathfinder.mjs';
import {isFunction} from '../../types/is.mjs';
import {attributeObserverSymbol} from "../customelement.mjs";
import {extractKeys} from "./extract-keys.mjs";
export {initOptionsFromAttributes};
......@@ -75,63 +76,10 @@ function initOptionsFromAttributes(element, options, mapping = {}, prefix = 'dat
}
finder.setVia(optionName, value);
// if element has an attribute observer, then register the attribute observer
if (element?.[attributeObserverSymbol]) {
element[attributeObserverSymbol][name] = (newValue, oldValue) => {
if (newValue === oldValue) return;
let changedValue = newValue;
if (typeOfOptionValue === 'boolean') {
changedValue = changedValue === 'true';
} else if (typeOfOptionValue === 'number') {
changedValue = Number(changedValue);
} else if (typeOfOptionValue === 'string') {
changedValue = String(changedValue);
} else if (typeOfOptionValue === 'object') {
changedValue = JSON.parse(changedValue);
}
finder.setVia(optionName, changedValue);
}
}
}
})
return options;
}
/**
* Extracts the keys from the given object and returns a map with the keys and values.
*
* @private
* @param {object} obj
* @param {string} keyPrefix
* @param {string} keySeparator
* @param {string} valueSeparator
* @returns {Map<any, any>}
*/
function extractKeys(obj, keyPrefix = '', keySeparator = '-', valueSeparator = '.') {
const resultMap = new Map();
function helper(currentObj, currentKeyPrefix, currentValuePrefix) {
for (const key in currentObj) {
if (typeof currentObj[key] === 'object' && !Array.isArray(currentObj[key])) {
const newKeyPrefix = currentKeyPrefix ? currentKeyPrefix + keySeparator + key.toLowerCase() : key.toLowerCase();
const newValuePrefix = currentValuePrefix ? currentValuePrefix + valueSeparator + key : key;
helper(currentObj[key], newKeyPrefix, newValuePrefix);
} else {
const finalKey = currentKeyPrefix ? currentKeyPrefix + keySeparator + key.toLowerCase() : key.toLowerCase();
const finalValue = currentValuePrefix ? currentValuePrefix + valueSeparator + key : key;
resultMap.set(finalKey, finalValue);
}
}
}
helper(obj, keyPrefix, keyPrefix);
return resultMap;
}
/**
* Copyright schukai GmbH and contributors 2023. All Rights Reserved.
* Node module: @schukai/monster
* This file is licensed under the AGPLv3 License.
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
*/
import {Pathfinder} from '../../data/pathfinder.mjs';
import {isFunction} from '../../types/is.mjs';
import {attributeObserverSymbol} from "../customelement.mjs";
import {extractKeys} from "./extract-keys.mjs";
export {setOptionFromAttribute};
/**
* Set the given options object based on the attributes of the current DOM element.
* The function looks for attributes with the prefix 'data-monster-option-', and maps them to
* properties in the options object. It replaces the dashes with dots to form the property path.
* For example, the attribute 'data-monster-option-url' maps to the 'url' property in the options object.
*
* With the mapping parameter, the attribute value can be mapped to a different value.
* 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'
* // and assigned to the 'bar' property in the options object.
* // e.g. <div data-monster-option-foo="foo"></div>
* 'bar.baz': (value) => value + 'bar'
* // the value of the attribute 'data-monster-option-bar-baz' is appended with 'bar'
* // and assigned to the 'bar.baz' property in the options object.
* // e.g. <div data-monster-option-bar-baz="foo"></div>
* }
*
* @since 3.45.0
* @param {HTMLElement} element - The DOM element to be used as the source of the attributes.
* @param {Object} name - The attribute object to be used as the source of the attributes.
* @param {Object} options - The options object to be initialized.
* @param {Object} mapping - A mapping between the attribute value and the property value.
* @param {string} prefix - The prefix of the attributes to be considered.
* @returns {Object} - The initialized options object.
* @this HTMLElement - The context of the DOM element.
*/
function setOptionFromAttribute(element, name, options, mapping = {}, prefix = 'data-monster-option-') {
if (!(element instanceof HTMLElement)) return options;
if (!element.hasAttributes()) return options;
const keyMap = extractKeys(options);
const finder = new Pathfinder(options);
// check if the attribute name is a valid option.
// the mapping between the attribute is simple. The dash is replaced by a dot.
// e.g. data-monster-url => url
const optionName = keyMap.get(name.substring(prefix.length).toLowerCase());
if (!finder.exists(optionName)) return;
if (!element.hasAttribute(name)) {
return options;
}
let value = element.getAttribute(name);
if (mapping.hasOwnProperty(optionName) && isFunction(mapping[optionName])) {
value = mapping[optionName](value);
}
const typeOfOptionValue = typeof finder.getVia(optionName);
if (typeOfOptionValue === 'boolean') {
value = value === 'true';
} else if (typeOfOptionValue === 'number') {
value = Number(value);
} else if (typeOfOptionValue === 'string') {
value = String(value);
} else if (typeOfOptionValue === 'object') {
value = JSON.parse(value);
}
finder.setVia(optionName, value);
return options;
}
......@@ -142,7 +142,7 @@ function getMonsterVersion() {
}
/** don't touch, replaced by make with package.json version */
monsterVersion = new Version("3.44.0");
monsterVersion = new Version("3.44.1");
return monsterVersion;
}
{
"name": "monster",
"version": "3.44.0",
"version": "3.44.1",
"description": "monster",
"repository": {
"type": "git",
......
......@@ -22,8 +22,9 @@
}
}
</script>
<monster-1>Monster1</monster-1>
<form>
<monster-1 data-monster-option-a-b-c="114">Monster1</monster-1>
</form>
</main>
</body>
</html>
......@@ -2,7 +2,7 @@
// import {Updater} from '../../../application/source/dom/updater.mjs';
import {
attributeObserverSymbol,
CustomElement,
CustomElement,CustomControl,
registerCustomElement
} from '../../../application/source/monster.mjs';
import {domReady} from '../../../application/source/dom/ready.mjs';
......@@ -12,7 +12,7 @@ import {domReady} from '../../../application/source/dom/ready.mjs';
const initMethodSymbol = Symbol.for("@schukai/monster/dom/@@initMethodSymbol");
class Monster1 extends CustomElement {
class Monster1 extends CustomControl {
constructor() {
super();
......
......@@ -1168,6 +1168,11 @@ packages:
engines: {node: '>=8'}
dev: true
/ansi-regex@6.0.1:
resolution: {integrity: sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==}
engines: {node: '>=12'}
dev: true
/ansi-styles@2.2.1:
resolution: {integrity: sha512-kmCevFghRiWM7HB5zTPULl4r9bVFSWjz62MhqizDGUrq2NWuNMQyuv4tHHoKJHs69M/MF64lEcHdYIocrdWQYA==}
engines: {node: '>=0.10.0'}
......@@ -1187,6 +1192,11 @@ packages:
color-convert: 2.0.1
dev: true
/ansi-styles@6.2.1:
resolution: {integrity: sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==}
engines: {node: '>=12'}
dev: true
/anymatch@3.1.3:
resolution: {integrity: sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==}
engines: {node: '>= 8'}
......@@ -1235,7 +1245,7 @@ packages:
postcss: ^8.1.0
dependencies:
browserslist: 4.21.5
caniuse-lite: 1.0.30001481
caniuse-lite: 1.0.30001482
fraction.js: 4.2.0
normalize-range: 0.1.2
picocolors: 1.0.0
......@@ -1312,8 +1322,8 @@ packages:
engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7}
hasBin: true
dependencies:
caniuse-lite: 1.0.30001481
electron-to-chromium: 1.4.377
caniuse-lite: 1.0.30001482
electron-to-chromium: 1.4.378
node-releases: 2.0.10
update-browserslist-db: 1.0.11(browserslist@4.21.5)
dev: true
......@@ -1387,13 +1397,13 @@ packages:
resolution: {integrity: sha512-bsTwuIg/BZZK/vreVTYYbSWoe2F+71P7K5QGEX+pT250DZbfU1MQ5prOKpPR+LL6uWKK3KMwMCAS74QB3Um1uw==}
dependencies:
browserslist: 4.21.5
caniuse-lite: 1.0.30001481
caniuse-lite: 1.0.30001482
lodash.memoize: 4.1.2
lodash.uniq: 4.5.0
dev: true
/caniuse-lite@1.0.30001481:
resolution: {integrity: sha512-KCqHwRnaa1InZBtqXzP98LPg0ajCVujMKjqKDhZEthIpAsJl/YEIa3YvXjGXPVqzZVguccuu7ga9KOE1J9rKPQ==}
/caniuse-lite@1.0.30001482:
resolution: {integrity: sha512-F1ZInsg53cegyjroxLNW9DmrEQ1SuGRTO1QlpA0o2/6OpQ0gFeDRoq1yFmnr8Sakn9qwwt9DmbxHB6w167OSuQ==}
dev: true
/catharsis@0.9.0:
......@@ -1527,15 +1537,6 @@ packages:
wrap-ansi: 7.0.0
dev: true
/cliui@8.0.1:
resolution: {integrity: sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==}
engines: {node: '>=12'}
dependencies:
string-width: 4.2.3
strip-ansi: 6.0.1
wrap-ansi: 7.0.0
dev: true
/code-block-writer@11.0.3:
resolution: {integrity: sha512-NiujjUFB4SwScJq2bwbYUtXbZhBSlY6vYzm++3Q6oC+U+injTqfPYFK8wS9COOmb2lueqp0ZRB4nK1VYeHgNyw==}
dev: true
......@@ -1884,8 +1885,12 @@ packages:
tslib: 2.5.0
dev: true
/electron-to-chromium@1.4.377:
resolution: {integrity: sha512-H3BYG6DW5Z+l0xcfXaicJGxrpA4kMlCxnN71+iNX+dBLkRMOdVJqFJiAmbNZZKA1zISpRg17JR03qGifXNsJtw==}
/eastasianwidth@0.2.0:
resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==}
dev: true
/electron-to-chromium@1.4.378:
resolution: {integrity: sha512-RfCD26kGStl6+XalfX3DGgt3z2DNwJS5DKRHCpkPq5T/PqpZMPB1moSRXuK9xhkt/sF57LlpzJgNoYl7mO7Z6w==}
dev: true
/emoji-regex@7.0.3:
......@@ -1896,6 +1901,10 @@ packages:
resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==}
dev: true
/emoji-regex@9.2.2:
resolution: {integrity: sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==}
dev: true
/end-of-stream@1.4.4:
resolution: {integrity: sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==}
dependencies:
......@@ -2253,7 +2262,7 @@ packages:
hasBin: true
dependencies:
foreground-child: 3.1.1
jackspeak: 2.1.1
jackspeak: 2.1.4
minimatch: 9.0.0
minipass: 5.0.0
path-scurry: 1.7.0
......@@ -2585,11 +2594,11 @@ packages:
istanbul-lib-report: 3.0.0
dev: true
/jackspeak@2.1.1:
resolution: {integrity: sha512-juf9stUEwUaILepraGOWIJTLwg48bUnBmRqd2ln2Os1sW987zeoj/hzhbvRB95oMuS2ZTpjULmdwHNX4rzZIZw==}
/jackspeak@2.1.4:
resolution: {integrity: sha512-7CGd4ZQu5M/FgQLlcgcsY858wf+ukg1ma5M95FACSfC54+88vm594Nv6C3NqWfk8wyK1u+E3SzvVsxr7bwONmg==}
engines: {node: '>=14'}
dependencies:
cliui: 8.0.1
cliui: github.com/isaacs/cliui/9f97090165675fdda63a79c29bc36bb1033506b0
optionalDependencies:
'@pkgjs/parseargs': 0.11.0
dev: true
......@@ -4212,6 +4221,15 @@ packages:
strip-ansi: 6.0.1
dev: true
/string-width@5.1.2:
resolution: {integrity: sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==}
engines: {node: '>=12'}
dependencies:
eastasianwidth: 0.2.0
emoji-regex: 9.2.2
strip-ansi: 7.0.1
dev: true
/string_decoder@1.1.1:
resolution: {integrity: sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==}
dependencies:
......@@ -4239,6 +4257,13 @@ packages:
ansi-regex: 5.0.1
dev: true
/strip-ansi@7.0.1:
resolution: {integrity: sha512-cXNxvT8dFNRVfhVME3JAe98mkXDYN2O1l7jmcwMnOslDeESg1rF/OZMtK0nRAhiari1unG5cD4jG3rapUAkLbw==}
engines: {node: '>=12'}
dependencies:
ansi-regex: 6.0.1
dev: true
/strip-final-newline@2.0.0:
resolution: {integrity: sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==}
engines: {node: '>=6'}
......@@ -4756,6 +4781,15 @@ packages:
strip-ansi: 6.0.1
dev: true
/wrap-ansi@8.1.0:
resolution: {integrity: sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==}
engines: {node: '>=12'}
dependencies:
ansi-styles: 6.2.1
string-width: 5.1.2
strip-ansi: 7.0.1
dev: true
/wrappy@1.0.2:
resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==}
dev: true
......@@ -4905,6 +4939,22 @@ packages:
commander: 9.5.0
dev: true
github.com/isaacs/cliui/9f97090165675fdda63a79c29bc36bb1033506b0:
resolution: {tarball: https://codeload.github.com/isaacs/cliui/tar.gz/9f97090165675fdda63a79c29bc36bb1033506b0}
name: cliui
version: 8.0.1
engines: {node: '>=12'}
prepare: true
requiresBuild: true
dependencies:
string-width: 5.1.2
string-width-cjs: /string-width@4.2.3
strip-ansi: 7.0.1
strip-ansi-cjs: /strip-ansi@6.0.1
wrap-ansi: 8.1.0
wrap-ansi-cjs: /wrap-ansi@7.0.0
dev: true
github.com/volker-schukai/jsdoc-external-example/e039186b531487bd1b1d5e2e1586a396b910c9d9:
resolution: {tarball: https://codeload.github.com/volker-schukai/jsdoc-external-example/tar.gz/e039186b531487bd1b1d5e2e1586a396b910c9d9}
name: jsdoc-external-example
......
......@@ -4,9 +4,9 @@ import chai from "chai"
import {ATTRIBUTE_OPTIONS} from "../../../../application/source/dom/constants.mjs";
import {getDocument} from "../../../../application/source/dom/util.mjs";
import {chaiDom} from "../../util/chai-dom.mjs";
import {cleanupDOMFromTesting, initMutationObserverForTesting} from "../../util/cleanupdom.mjs";
import {initJSDOM} from "../../util/jsdom.mjs";
let expect = chai.expect;
chai.use(chaiDom);
......@@ -19,8 +19,6 @@ describe('DOM', function () {
let CustomControl, registerCustomElement, TestComponent, document, jsdomFlag;
describe('CustomControl()', function () {
before(function (done) {
initJSDOM().then(() => {
......@@ -57,7 +55,10 @@ describe('DOM', function () {
});
})
describe('CustomControl()', function () {
beforeEach(() => {
initMutationObserverForTesting()
let mocks = document.getElementById('mocks');
mocks.innerHTML = html1;
})
......@@ -65,6 +66,8 @@ describe('DOM', function () {
afterEach(() => {
let mocks = document.getElementById('mocks');
mocks.innerHTML = "";
cleanupDOMFromTesting();
})
describe('create', function () {
......@@ -85,19 +88,24 @@ describe('DOM', function () {
});
});
describe('Options change', function () {
it('delegatesFocus should change from true to false', function () {
let element = document.createElement('monster-customcontrol')
expect(element.getOption('delegatesFocus')).to.be.true;
element.setAttribute(ATTRIBUTE_OPTIONS, JSON.stringify({delegatesFocus: false}));
expect(element.getOption('delegatesFocus')).to.be.false;
})
})
// describe('Options change', function () {
//
// it('delegatesFocus should change from true to false', function (done) {
// let element = document.createElement('monster-customcontrol')
//
// expect(element.getOption('delegatesFocus')).to.be.true;
// setTimeout(() => {
// element.setAttribute(ATTRIBUTE_OPTIONS, JSON.stringify({delegatesFocus: false}));
// setTimeout(() => {
// expect(element.getOption('delegatesFocus')).to.be.false;
// done();
// }, 10);
// }, 10);
//
//
// }).timeout(100);
//
// })
describe('Test ElementInternals', function () {
......@@ -115,6 +123,7 @@ describe('DOM', function () {
expect(d.constructor.formAssociated).to.be.true;
});
it('form', function () {
let d = document.createElement('monster-customcontrol');
......@@ -147,7 +156,6 @@ describe('DOM', function () {
});
it('setFormValue', function () {
let d = document.createElement('monster-customcontrol');
......@@ -161,7 +169,6 @@ describe('DOM', function () {
});
it('name getter', function () {
let d = document.createElement('monster-customcontrol');
......
......@@ -277,12 +277,12 @@ describe('DOM', function () {
expect(element.getOption('delegatesFocus')).to.be.true;
expect(Object.is(element[internalSymbol].realSubject, o)).to.be.true;
element.setAttribute(ATTRIBUTE_OPTIONS, JSON.stringify({delegatesFocus: false}));
expect(Object.is(element[internalSymbol].realSubject, o)).to.be.true;
expect(element.getOption('delegatesFocus')).to.be.false;
expect(element[internalSymbol].realSubject.options.delegatesFocus).to.be.false;
expect(Object.is(element[internalSymbol].realSubject, o)).to.be.true;
// element.setAttribute(ATTRIBUTE_OPTIONS, JSON.stringify({delegatesFocus: false}));
// expect(Object.is(element[internalSymbol].realSubject, o)).to.be.true;
//
// expect(element.getOption('delegatesFocus')).to.be.false;
// expect(element[internalSymbol].realSubject.options.delegatesFocus).to.be.false;
// expect(Object.is(element[internalSymbol].realSubject, o)).to.be.true;
})
......
......@@ -55,7 +55,6 @@ describe('FocusManager', function () {
});
}
})
it('run ist', function () {
......
......@@ -7,7 +7,7 @@ describe('Monster', function () {
let monsterVersion
/** don´t touch, replaced by make with package.json version */
monsterVersion = new Version("3.44.0")
monsterVersion = new Version("3.44.1")
let m = getMonsterVersion();
......
......@@ -16,14 +16,10 @@ function init() {
}
})
}
});
});
}
/**
*
*/
......
{"version":"3.44.1"}
{"version":"3.46.0"}