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

chore: some small code tweaks

parent 2b5da003
No related branches found
No related tags found
No related merge requests found
......@@ -119,6 +119,50 @@
</monster-tree-menu>
</monster-panel>
<monster-panel id="inner3" data-monster-option-heightadjustment="5"
slot="end">
<monster-tree-menu
data-monster-option-mapping-idtemplate="id"
data-monster-option-mapping-parentkey="parent_id"
data-monster-option-mapping-labeltemplate="${title}"
data-monster-option-mapping-valuetemplate="${path:url | tostring}"
data-monster-option-mapping-icontemplate="${path:icon | default:default}"
data-monster-option-datasource-selector="#menu-rest"
value=""
>
<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
<symbol id="box" viewBox="0 0 16 16">
<path d="M6 9a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3A.5.5 0 0 1 6 9M3.854 4.146a.5.5 0 1 0-.708.708L4.793 6.5 3.146 8.146a.5.5 0 1 0 .708.708l2-2a.5.5 0 0 0 0-.708z"/>
<path d="M2 1a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V3a2 2 0 0 0-2-2zm12 1a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1z"/>
</symbol>
<symbol id="default" viewBox="0 0 16 16">
<path d="M11 2a3 3 0 0 1 3 3v6a3 3 0 0 1-3 3H5a3 3 0 0 1-3-3V5a3 3 0 0 1 3-3zM5 1a4 4 0 0 0-4 4v6a4 4 0 0 0 4 4h6a4 4 0 0 0 4-4V5a4 4 0 0 0-4-4z"/>
</symbol>
<symbol id="balloon" viewBox="0 0 16 16">
<path d="M8 9.984C10.403 9.506 12 7.48 12 5a4 4 0 0 0-8 0c0 2.48 1.597 4.506 4 4.984M13 5c0 2.837-1.789 5.227-4.52 5.901l.244.487a.25.25 0 1 1-.448.224l-.008-.017c.008.11.02.202.037.29.054.27.161.488.419 1.003.288.578.235 1.15.076 1.629-.157.469-.422.867-.588 1.115l-.004.007a.25.25 0 1 1-.416-.278c.168-.252.4-.6.533-1.003.133-.396.163-.824-.049-1.246l-.013-.028c-.24-.48-.38-.758-.448-1.102a3 3 0 0 1-.052-.45l-.04.08a.25.25 0 1 1-.447-.224l.244-.487C4.789 10.227 3 7.837 3 5a5 5 0 0 1 10 0m-6.938-.495a2 2 0 0 1 1.443-1.443C7.773 2.994 8 2.776 8 2.5s-.226-.504-.498-.459a3 3 0 0 0-2.46 2.461c-.046.272.182.498.458.498s.494-.227.562-.495"/>
</symbol>
<symbol id="cart" viewBox="0 0 16 16">
<path d="M8 1a2.5 2.5 0 0 1 2.5 2.5V4h-5v-.5A2.5 2.5 0 0 1 8 1m3.5 3v-.5a3.5 3.5 0 1 0-7 0V4H1v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V4zM2 5h12v9a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1z"/>
</symbol>
<symbol id="box2" viewBox="0 0 16 16">
<path d="M8 7.982C9.664 6.309 13.825 9.236 8 13 2.175 9.236 6.336 6.31 8 7.982"/>
<path d="M3.75 0a1 1 0 0 0-.8.4L.1 4.2a.5.5 0 0 0-.1.3V15a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1V4.5a.5.5 0 0 0-.1-.3L13.05.4a1 1 0 0 0-.8-.4zm0 1H7.5v3h-6zM8.5 4V1h3.75l2.25 3zM15 5v10H1V5z"/>
</symbol>
</svg>
</monster-tree-menu>
</monster-panel>
</monster-split-panel>
</monster-panel>
</main>
......
......@@ -21,10 +21,11 @@ setTimeout(() => {
const obj = document.querySelector("monster-tree-menu");
obj.selectEntry("/alvine/?cmd=9130")
setTimeout(() => {
//obj.selectEntry("/ebay")
obj.selectEntry("/alvine/?cmd=8157")
}, 1000)
// setTimeout(() => {
// //obj.selectEntry("/ebay")
// console.log(obj)
// obj.selectEntry("/alvine/?cmd=9201")
// }, 5000)
}, 1000)
......
......@@ -217,6 +217,7 @@ class TreeMenu extends CustomElement {
* @param value
*/
selectEntry(value) {
this.shadowRoot
.querySelectorAll("[data-monster-role=entry]")
.forEach((entry) => {
......@@ -241,6 +242,7 @@ class TreeMenu extends CustomElement {
let intend = parseInt(currentNode.getAttribute(ATTRIBUTE_INTEND));
if (intend > 0) {
const refSet = new Set()
let ref = currentNode.previousElementSibling;
while (ref && ref.hasAttribute(ATTRIBUTE_INTEND)) {
const i = parseInt(ref.getAttribute(ATTRIBUTE_INTEND));
......@@ -252,6 +254,11 @@ class TreeMenu extends CustomElement {
if (i < intend) {
if (ref.getAttribute("data-monster-state") !== "open") {
ref.click();
//console.log(ref.getAttribute("data-monster-state") )
//refSet.add(ref)
//console.log(ref)
}
if (i === 0) {
......@@ -261,6 +268,13 @@ class TreeMenu extends CustomElement {
}
ref = ref.previousElementSibling;
}
// if (refSet.size > 0) {
// console.log(refSet)
// refSet.forEach((ref) => {
// ref.click();
// })
// }
}
}
}
......@@ -311,7 +325,10 @@ function initEventHandler() {
return;
}
this[preventChangeSymbol] = true;
setTimeout(() => {
importEntries.call(this);
},10)
}),
);
});
......@@ -500,7 +517,10 @@ function importEntries() {
}
}
setTimeout(() => {
this.setOption("entries", options);
},5)
return this;
}
......
......@@ -180,7 +180,8 @@ class Pathfinder extends Base {
try {
getValueViaPath.call(this, this.object, path, true);
return true;
} catch (e) {}
} catch (e) {
}
return false;
}
......@@ -223,14 +224,13 @@ function iterate(subject, path, check) {
/**
*
* @param {*} subject
* @param [string|array} path
* @param [boolean} check
* @returns {*}
* @param subject
* @param path
* @param check
* @returns {V|*|Map}
* @throws {TypeError} unsupported type
* @throws {Error} the journey is not at its end
* @throws {Error} unsupported action for this data type
* @private
*/
function getValueViaPath(subject, path, check) {
if (check === undefined) {
......@@ -239,7 +239,7 @@ function getValueViaPath(subject, path, check) {
validateBoolean(check);
if (!(isArray(path) || isString(path))) {
throw new Error("type error: path must be a string or an array");
throw new Error("type error: a path must be a string or an array in getValueViaPath");
}
let parts;
......@@ -266,7 +266,7 @@ function getValueViaPath(subject, path, check) {
validateInteger(current);
anchor = [...subject]?.[current];
} else if (typeof WeakRef === "function" && subject instanceof WeakRef) {
throw Error("unsupported action for this data type");
throw Error("unsupported action for this data type (WeakRef)");
} else if (isArray(subject)) {
current = parseInt(current);
validateInteger(current);
......@@ -290,14 +290,14 @@ function getValueViaPath(subject, path, check) {
);
if (!subject.hasOwnProperty(current) && descriptor === undefined) {
throw Error("unknown value");
throw Error("unknown value " + current);
}
}
return anchor;
}
throw TypeError(`unsupported type ${typeof subject}`);
throw TypeError(`unsupported type ${typeof subject} for path ${path}`);
}
/**
......@@ -314,13 +314,13 @@ function getValueViaPath(subject, path, check) {
*/
function setValueViaPath(subject, path, value) {
if (!(isArray(path) || isString(path))) {
throw new Error("type error: path must be a string or an array");
throw new Error("type error: a path must be a string or an array");
}
let parts;
if (isArray(path)) {
if (path.length === 0) {
return subject;
return;
}
parts = path;
......@@ -337,7 +337,8 @@ function setValueViaPath(subject, path, value) {
try {
getValueViaPath.call(this, subject, current, true);
break;
} catch (e) {}
} catch (e) {
}
stack.push(current);
parts.pop();
......@@ -363,7 +364,7 @@ function setValueViaPath(subject, path, value) {
const anchor = getValueViaPath.call(this, subject, subpath);
if (!(isObject(subject) || isArray(subject))) {
throw TypeError(`unsupported type: ${typeof subject}`);
throw TypeError(`unsupported type: ${typeof subject} in setValueViaPath`);
}
if (anchor instanceof Map || anchor instanceof WeakMap) {
......@@ -371,11 +372,11 @@ function setValueViaPath(subject, path, value) {
} else if (anchor instanceof Set || anchor instanceof WeakSet) {
anchor.append(value);
} else if (typeof WeakRef === "function" && anchor instanceof WeakRef) {
throw Error("unsupported action for this data type");
throw Error("unsupported action for this data type in setValueViaPath");
} else if (isArray(anchor)) {
last = parseInt(last);
validateInteger(last);
assignProperty(anchor, last, value);
assignProperty(anchor, "" + last, value);
} else {
assignProperty(anchor, last, value);
}
......@@ -415,13 +416,13 @@ function assignProperty(object, key, value) {
*/
function deleteValueViaPath(subject, path) {
if (!(isArray(path) || isString(path))) {
throw new Error("type error: path must be a string or an array");
throw new Error("type error: a path must be a string or an array in deleteValueViaPath");
}
let parts;
if (isArray(path)) {
if (path.length === 0) {
return subject;
return;
}
parts = path;
......@@ -430,9 +431,9 @@ function deleteValueViaPath(subject, path) {
}
let last = parts.pop();
const subpath = parts.join(DELIMITER);
const subPath = parts.join(DELIMITER);
const anchor = getValueViaPath.call(this, subject, subpath);
const anchor = getValueViaPath.call(this, subject, subPath);
if (anchor instanceof Map) {
anchor.delete(last);
......@@ -442,7 +443,7 @@ function deleteValueViaPath(subject, path) {
anchor instanceof WeakSet ||
(typeof WeakRef === "function" && anchor instanceof WeakRef)
) {
throw Error("unsupported action for this data type");
throw Error("unsupported action for this data type in deleteValueViaPath");
} else if (isArray(anchor)) {
last = parseInt(last);
validateInteger(last);
......
......@@ -221,7 +221,7 @@ class Updater extends Base {
* If you have passed a ProxyObserver in the constructor, you will get the object that the ProxyObserver manages here.
* However, if you passed a simple object, here you will get a proxy for that object.
*
* For changes the ProxyObserver must be used.
* For changes, the ProxyObserver must be used.
*
* @since 1.8.0
* @return {Proxy}
......@@ -534,7 +534,7 @@ function insertElement(change) {
const available = new Set();
for (const [i, obj] of Object.entries(value)) {
for (const [i, ] of Object.entries(value)) {
const ref = refPrefix + i;
const currentPath = `${dataPath}.${i}`;
......
......@@ -69,11 +69,12 @@ describe('Pathfinder', function () {
it('.setVia(' + a + ') should result in ' + b, function () {
let r = pf.getVia(a);
let i = convertMapResult(r);
expect(JSON.stringify(i)).is.equal(b);
});
});
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment