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

fix: exchange of document.selector with function findElementWithSelectorUpwards #199

parent 613bc97c
No related branches found
No related tags found
No related merge requests found
...@@ -20,40 +20,40 @@ before_script: ...@@ -20,40 +20,40 @@ before_script:
after_script: after_script:
- nix develop .#gitlab --command clean-up - nix develop .#gitlab --command clean-up
#tests: tests:
# stage: test stage: test
# tags: tags:
# - nixos-gen3 - nixos-gen3
# script: script:
# - nix develop .#gitlab --command run-ci-tests - nix develop .#gitlab --command run-ci-tests
# cache: cache:
# untracked: true untracked: true
# key: key:
# files: files:
# - pnpm-lock.yaml - pnpm-lock.yaml
# paths: paths:
# - node_modules/ - node_modules/
# rules: rules:
# - if: $DEPLOY_VERSION == null - if: $DEPLOY_VERSION == null
#
#web-tests: web-tests:
# stage: test stage: test
# tags: tags:
# - nixos-gen3 - nixos-gen3
# script: script:
# - nix develop .#gitlab --command run-ci-web-tests - nix develop .#gitlab --command run-ci-web-tests
# cache: cache:
# untracked: true untracked: true
# key: key:
# files: files:
# - pnpm-lock.yaml - pnpm-lock.yaml
# paths: paths:
# - node_modules/ - node_modules/
# artifacts: artifacts:
# paths: paths:
# - screenshot.png - screenshot.png
# rules: rules:
# - if: $DEPLOY_VERSION == null - if: $DEPLOY_VERSION == null
release: release:
stage: release stage: release
......
# Changelog # Changelog
## [3.65.20] - 2024-06-20 ## [3.65.20] - 2024-06-20
### Bug Fixes - Changeover to new release process
- wip new pipeline
- wip new pipeline
## [3.65.19] - 2024-06-20
### Bug Fixes
- wip new pipeline
## [3.65.18] - 2024-06-20
### Bug Fixes
- wip new pipeline
## [3.65.17] - 2024-06-20
### Bug Fixes
- wip new pipeline
## [3.65.16] - 2024-06-20
### Bug Fixes
- wip new pipeline
## [3.65.15] - 2024-06-20
## [3.65.3] - 2024-06-19 ## [3.65.3] - 2024-06-19
### Bug Fixes ### Bug Fixes
- switch nodejs_22 to nodejs_20 - switch nodejs_22 to nodejs_20 (segmentation fault)
## [3.65.1] - 2024-06-17 ## [3.65.1] - 2024-06-17
......
...@@ -2,7 +2,7 @@ export const projectRoot = "/home/vs/workspaces/oss/monster/monster"; ...@@ -2,7 +2,7 @@ export const projectRoot = "/home/vs/workspaces/oss/monster/monster";
export const sourcePath = "/home/vs/workspaces/oss/monster/monster/source"; export const sourcePath = "/home/vs/workspaces/oss/monster/monster/source";
export const developmentPath = "/home/vs/workspaces/oss/monster/monster/development"; export const developmentPath = "/home/vs/workspaces/oss/monster/monster/development";
export const pnpxBin = "/nix/store/77wblnm5dnmgnan3695j3mk4r7j75s5j-pnpm-8.15.5/bin/pnpx"; export const pnpxBin = "/nix/store/77wblnm5dnmgnan3695j3mk4r7j75s5j-pnpm-8.15.5/bin/pnpx";
export const nodeBin = "/nix/store/72m3szv59j74b12dmicmayvvlikh65qc-nodejs-22.2.0/bin/node"; export const nodeBin = "/nix/store/6g9n96qf1yx139xklnmy3v4xhjvjgsji-nodejs-20.12.2/bin/node";
export const license = "/**" + "\n" + export const license = "/**" + "\n" +
" * Copyright © schukai GmbH and all contributing authors, {{copyRightYear}}. All rights reserved." + "\n" + " * Copyright © schukai GmbH and all contributing authors, {{copyRightYear}}. All rights reserved." + "\n" +
" * Node module: @schukai/monster" + "\n" + " * Node module: @schukai/monster" + "\n" +
......
...@@ -15,8 +15,6 @@ in ...@@ -15,8 +15,6 @@ in
archive=$(ls ${monster} | grep tgz) archive=$(ls ${monster} | grep tgz)
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc
${pkgs'.nodejs_20}/bin/npm publish "${monster}/$archive"
if ! publishingResult=$(${pkgs'.nodejs_20}/bin/npm publish "${monster}/$archive" --no-git-checks --access public) if ! publishingResult=$(${pkgs'.nodejs_20}/bin/npm publish "${monster}/$archive" --no-git-checks --access public)
then then
if [ -f .npmrc ] ; then rm .npmrc ; fi if [ -f .npmrc ] ; then rm .npmrc ; fi
......
...@@ -20,6 +20,7 @@ import { ...@@ -20,6 +20,7 @@ import {
CustomElement, CustomElement,
registerCustomElement, registerCustomElement,
} from "../../dom/customelement.mjs"; } from "../../dom/customelement.mjs";
import {findElementWithSelectorUpwards} from "../../dom/util.mjs";
import { isString } from "../../types/is.mjs"; import { isString } from "../../types/is.mjs";
import { State } from "../form/types/state.mjs"; import { State } from "../form/types/state.mjs";
import "../form/state-button.mjs"; import "../form/state-button.mjs";
...@@ -189,12 +190,12 @@ function initControlReferences() { ...@@ -189,12 +190,12 @@ function initControlReferences() {
const selector = this.getOption("dataset.selector"); const selector = this.getOption("dataset.selector");
if (isString(selector)) { if (isString(selector)) {
const elements = document.querySelectorAll(selector);
if (elements.length !== 1) { const element = findElementWithSelectorUpwards( this,selector);
if (element===null) {
throw new Error("the selector must match exactly one element"); throw new Error("the selector must match exactly one element");
} }
const element = elements[0];
if (!(element instanceof HTMLElement)) { if (!(element instanceof HTMLElement)) {
throw new TypeError("the element must be a dataset"); throw new TypeError("the element must be a dataset");
} }
...@@ -205,12 +206,11 @@ function initControlReferences() { ...@@ -205,12 +206,11 @@ function initControlReferences() {
const selector2 = this.getOption("overlay.selector"); const selector2 = this.getOption("overlay.selector");
if (isString(selector2)) { if (isString(selector2)) {
const elements = document.querySelectorAll(selector2); const element = findElementWithSelectorUpwards( this,selector);
if (elements.length !== 1) { if (element===null) {
throw new Error("the selector must match exactly one element"); throw new Error("the selector must match exactly one element");
} }
const element = elements[0];
if (!(element instanceof HTMLElement)) { if (!(element instanceof HTMLElement)) {
throw new TypeError("the element must be a overlay"); throw new TypeError("the element must be a overlay");
} }
......
...@@ -22,6 +22,7 @@ import { ...@@ -22,6 +22,7 @@ import {
attributeObserverSymbol, attributeObserverSymbol,
registerCustomElement, registerCustomElement,
} from "../../dom/customelement.mjs"; } from "../../dom/customelement.mjs";
import {findElementWithSelectorUpwards} from "../../dom/util.mjs";
import {isString} from "../../types/is.mjs"; import {isString} from "../../types/is.mjs";
import {Observer} from "../../types/observer.mjs"; import {Observer} from "../../types/observer.mjs";
import {clone} from "../../util/clone.mjs"; import {clone} from "../../util/clone.mjs";
...@@ -216,12 +217,11 @@ class DataSet extends CustomElement { ...@@ -216,12 +217,11 @@ class DataSet extends CustomElement {
const selector = this.getOption("datasource.selector"); const selector = this.getOption("datasource.selector");
if (isString(selector)) { if (isString(selector)) {
const elements = document.querySelectorAll(selector); const element = findElementWithSelectorUpwards(this, selector);
if (elements.length !== 1) { if (element === null) {
throw new Error("the selector must match exactly one element"); throw new Error("the selector must match exactly one element");
} }
const element = elements[0];
if (!(element instanceof Datasource)) { if (!(element instanceof Datasource)) {
throw new TypeError("the element must be a datasource"); throw new TypeError("the element must be a datasource");
} }
......
...@@ -511,8 +511,7 @@ function getFilterConfigKey() { ...@@ -511,8 +511,7 @@ function getFilterConfigKey() {
* @returns {Promise} * @returns {Promise}
*/ */
function getHostConfig(callback) { function getHostConfig(callback) {
const document = getDocument(); const host = findElementWithSelectorUpwards( this,"monster-host");
const host = document.querySelector("monster-host");
if (!(host && this.id)) { if (!(host && this.id)) {
return Promise.resolve({}); return Promise.resolve({});
...@@ -608,8 +607,7 @@ function updateConfigColumnBar() { ...@@ -608,8 +607,7 @@ function updateConfigColumnBar() {
map[option.name] = option.visible; map[option.name] = option.visible;
} }
const document = getDocument(); const host = findElementWithSelectorUpwards( this,"monster-host");
const host = document.querySelector("monster-host");
if (!(host && this.id)) { if (!(host && this.id)) {
return; return;
} }
...@@ -816,8 +814,7 @@ function storeOrderStatement(doFetch) { ...@@ -816,8 +814,7 @@ function storeOrderStatement(doFetch) {
const statement = createOrderStatement(headers); const statement = createOrderStatement(headers);
setDataSource.call(this, { orderBy: statement }, doFetch); setDataSource.call(this, { orderBy: statement }, doFetch);
const document = getDocument(); const host = findElementWithSelectorUpwards( this,"monster-host");
const host = document.querySelector("monster-host");
if (!(host && this.id)) { if (!(host && this.id)) {
return; return;
} }
......
...@@ -726,8 +726,7 @@ function initTabEvents() { ...@@ -726,8 +726,7 @@ function initTabEvents() {
} }
} }
const document = getDocument(); const host = findElementWithSelectorUpwards( this,"monster-host");
const host = document.querySelector("monster-host");
if (!(host && this.id)) { if (!(host && this.id)) {
return; return;
} }
...@@ -768,8 +767,7 @@ function updateFilterTabs() { ...@@ -768,8 +767,7 @@ function updateFilterTabs() {
return; return;
} }
const document = getDocument(); const host = findElementWithSelectorUpwards( this,"monster-host");
const host = document.querySelector("monster-host");
if (!(host && this.id)) { if (!(host && this.id)) {
return; return;
} }
...@@ -1067,8 +1065,7 @@ function getControlValuesFromLabel(label) { ...@@ -1067,8 +1065,7 @@ function getControlValuesFromLabel(label) {
* @returns {Promise<unknown>} * @returns {Promise<unknown>}
*/ */
function initFromConfig() { function initFromConfig() {
const document = getDocument(); const host = findElementWithSelectorUpwards( this,"monster-host");
const host = document.querySelector("monster-host");
if (!(isInstance(host, Host) && this.id)) { if (!(isInstance(host, Host) && this.id)) {
return Promise.resolve(); return Promise.resolve();
...@@ -1111,8 +1108,7 @@ function initFromConfig() { ...@@ -1111,8 +1108,7 @@ function initFromConfig() {
* @private * @private
*/ */
function updateConfig() { function updateConfig() {
const document = getDocument(); const host = findElementWithSelectorUpwards( this,"monster-host");
const host = document.querySelector("monster-host");
if (!(host && this.id)) { if (!(host && this.id)) {
return; return;
} }
......
...@@ -17,6 +17,7 @@ import { ...@@ -17,6 +17,7 @@ import {
CustomElement, CustomElement,
registerCustomElement, registerCustomElement,
} from "../../dom/customelement.mjs"; } from "../../dom/customelement.mjs";
import {findElementWithSelectorUpwards} from "../../dom/util.mjs";
import { ThemeStyleSheet } from "../stylesheet/theme.mjs"; import { ThemeStyleSheet } from "../stylesheet/theme.mjs";
import { ATTRIBUTE_DATASOURCE_SELECTOR } from "./constants.mjs"; import { ATTRIBUTE_DATASOURCE_SELECTOR } from "./constants.mjs";
import { Datasource } from "./datasource.mjs"; import { Datasource } from "./datasource.mjs";
...@@ -188,12 +189,11 @@ class Pagination extends CustomElement { ...@@ -188,12 +189,11 @@ class Pagination extends CustomElement {
const selector = this.getOption("datasource.selector", ""); const selector = this.getOption("datasource.selector", "");
if (isString(selector)) { if (isString(selector)) {
const elements = document.querySelectorAll(selector); const element = findElementWithSelectorUpwards( this,selector);
if (elements.length !== 1) { if (element===null) {
throw new Error("the selector must match exactly one element"); throw new Error("the selector must match exactly one element");
} }
const element = elements[0];
if (!(element instanceof Datasource)) { if (!(element instanceof Datasource)) {
throw new TypeError("the element must be a datasource"); throw new TypeError("the element must be a datasource");
} }
......
...@@ -22,6 +22,7 @@ import { ...@@ -22,6 +22,7 @@ import {
attributeObserverSymbol, attributeObserverSymbol,
registerCustomElement, registerCustomElement,
} from "../../dom/customelement.mjs"; } from "../../dom/customelement.mjs";
import {findElementWithSelectorUpwards} from "../../dom/util.mjs";
import { isString, isArray } from "../../types/is.mjs"; import { isString, isArray } from "../../types/is.mjs";
import { Observer } from "../../types/observer.mjs"; import { Observer } from "../../types/observer.mjs";
import { TokenList } from "../../types/tokenlist.mjs"; import { TokenList } from "../../types/tokenlist.mjs";
...@@ -154,12 +155,12 @@ class SaveButton extends CustomElement { ...@@ -154,12 +155,12 @@ class SaveButton extends CustomElement {
const selector = this.getOption("datasource.selector"); const selector = this.getOption("datasource.selector");
if (isString(selector)) { if (isString(selector)) {
const elements = document.querySelectorAll(selector);
if (elements.length !== 1) { const element = findElementWithSelectorUpwards( this,selector);
if (element===null) {
throw new Error("the selector must match exactly one element"); throw new Error("the selector must match exactly one element");
} }
const element = elements[0];
if (!(element instanceof Datasource)) { if (!(element instanceof Datasource)) {
throw new TypeError("the element must be a datasource"); throw new TypeError("the element must be a datasource");
} }
......
...@@ -17,6 +17,7 @@ import { ...@@ -17,6 +17,7 @@ import {
CustomElement, CustomElement,
registerCustomElement, registerCustomElement,
} from "../../dom/customelement.mjs"; } from "../../dom/customelement.mjs";
import {findElementWithSelectorUpwards} from "../../dom/util.mjs";
import { ThemeStyleSheet } from "../stylesheet/theme.mjs"; import { ThemeStyleSheet } from "../stylesheet/theme.mjs";
import { Datasource } from "./datasource.mjs"; import { Datasource } from "./datasource.mjs";
import { SpinnerStyleSheet } from "../stylesheet/spinner.mjs"; import { SpinnerStyleSheet } from "../stylesheet/spinner.mjs";
...@@ -174,12 +175,12 @@ function initEventHandler() { ...@@ -174,12 +175,12 @@ function initEventHandler() {
const self = this; const self = this;
if (isString(selector)) { if (isString(selector)) {
const elements = document.querySelectorAll(selector);
if (elements.length !== 1) { const element = findElementWithSelectorUpwards( this,selector);
if (element===null) {
throw new Error("the selector must match exactly one element"); throw new Error("the selector must match exactly one element");
} }
const element = elements[0];
if (!(element instanceof Datasource)) { if (!(element instanceof Datasource)) {
throw new TypeError("the element must be a datasource"); throw new TypeError("the element must be a datasource");
} }
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
*/ */
import {instanceSymbol} from "../../constants.mjs"; import {instanceSymbol} from "../../constants.mjs";
import {findElementWithSelectorUpwards} from "../../dom/util.mjs";
import {isObject} from "../../types/is.mjs"; import {isObject} from "../../types/is.mjs";
import {Datasource} from "../datasource.mjs"; import {Datasource} from "../datasource.mjs";
...@@ -74,9 +75,9 @@ class DomStorage extends Datasource { ...@@ -74,9 +75,9 @@ class DomStorage extends Datasource {
throw new Error("The read selector is not defined"); throw new Error("The read selector is not defined");
} }
const storage = document.querySelector(selector); const storage = findElementWithSelectorUpwards(this, selector);
if (!storage) { if (!storage) {
throw new Error("There are no storage element"); throw new Error("There is no storage element");
} }
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
...@@ -98,12 +99,12 @@ class DomStorage extends Datasource { ...@@ -98,12 +99,12 @@ class DomStorage extends Datasource {
write() { write() {
const selector = this.getOption("write.selector"); const selector = this.getOption("write.selector");
if (!selector) { if (!selector) {
throw new Error("The write selector is not defined"); throw new Error("The option write.selector is not defined");
} }
const storage = document.querySelector(selector); const storage = findElementWithSelectorUpwards(this, selector);
if (!storage) { if (!storage) {
throw new Error("There are no storage element"); throw new Error("There is no storage element");
} }
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
......
...@@ -242,7 +242,6 @@ function addEvents() { ...@@ -242,7 +242,6 @@ function addEvents() {
this[referenceSymbol].removeEventListener("error", onError); this[referenceSymbol].removeEventListener("error", onError);
this[referenceSymbol].removeEventListener("load", onLoad); this[referenceSymbol].removeEventListener("load", onLoad);
this[internalStateSymbol].getSubject()["loaded"] = true; this[internalStateSymbol].getSubject()["loaded"] = true;
return;
}; };
this[referenceSymbol].addEventListener("load", onLoad, false); this[referenceSymbol].addEventListener("load", onLoad, false);
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
import {internalStateSymbol} from "../../constants.mjs"; import {internalStateSymbol} from "../../constants.mjs";
import {extend} from "../../data/extend.mjs"; import {extend} from "../../data/extend.mjs";
import {getGlobalFunction} from "../../types/global.mjs"; import {getGlobalFunction} from "../../types/global.mjs";
import {addAttributeToken} from "../attributes.mjs";
import { import {
ATTRIBUTE_CLASS, ATTRIBUTE_CLASS,
ATTRIBUTE_ERRORMESSAGE, ATTRIBUTE_ERRORMESSAGE,
...@@ -31,6 +32,7 @@ import { ...@@ -31,6 +32,7 @@ import {
Resource, Resource,
} from "../resource.mjs"; } from "../resource.mjs";
import {instanceSymbol} from "../../constants.mjs"; import {instanceSymbol} from "../../constants.mjs";
export {Data}; export {Data};
/** /**
...@@ -72,6 +74,7 @@ class Data extends Resource { ...@@ -72,6 +74,7 @@ class Data extends Resource {
* @return {Monster.DOM.Resource} * @return {Monster.DOM.Resource}
*/ */
connect() { connect() {
const self = this;
if (!(this[referenceSymbol] instanceof HTMLElement)) { if (!(this[referenceSymbol] instanceof HTMLElement)) {
this.create(); this.create();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment