diff --git a/package.json b/package.json
index 424c84704..ee40b4044 100644
--- a/package.json
+++ b/package.json
@@ -16,7 +16,6 @@
"@stomp/stompjs": "^7.5.0",
"dompurify": "^3.5.0",
"highlight.js": "^11.12.0",
- "imagesloaded": "^4.1.4",
"jquery": "^3.7.1",
"jquery-jcrop": "^0.9.13",
"luxon": "3.7.2",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 5584bb33d..3efb610c8 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -205,9 +205,6 @@ importers:
highlight.js:
specifier: ^11.12.0
version: 11.12.0
- imagesloaded:
- specifier: ^4.1.4
- version: 4.1.4
jquery:
specifier: ^3.7.1
version: 3.7.1
diff --git a/src/pat/carousel/carousel.js b/src/pat/carousel/carousel.js
index b0368e512..b7a8f7a28 100644
--- a/src/pat/carousel/carousel.js
+++ b/src/pat/carousel/carousel.js
@@ -7,6 +7,7 @@ import $ from "jquery";
import Base from "../../core/base";
import logging from "../../core/logging";
import Parser from "../../core/parser";
+import utils from "../../core/utils";
const log = logging.getLogger("pat.carousel");
@@ -31,7 +32,6 @@ export default Base.extend({
import("slick-carousel/slick/slick.scss");
}
await import("slick-carousel");
- const ImagesLoaded = (await import("imagesloaded")).default;
this.options = parser.parse(this.el, this.options);
this.settings = {
@@ -49,7 +49,19 @@ export default Base.extend({
this.settings.appendDots = this.options.appendDots;
}
- ImagesLoaded(this.el, () => this.setup());
+ this.setup();
+
+ // Recalculate the carousel dimensions whenever an image within has
+ // been loaded or failed loading. The load and error events do not
+ // bubble, but can be captured. This also catches images which are
+ // added later.
+ const update = utils.debounce(() => {
+ if (this.el.classList.contains("slick-initialized")) {
+ $(this.el).slick("setPosition");
+ }
+ }, 100);
+ this.el.addEventListener("load", update, true);
+ this.el.addEventListener("error", update, true);
},
setup() {
diff --git a/src/pat/carousel/carousel.test.js b/src/pat/carousel/carousel.test.js
index caf1f171b..0dfab15a9 100644
--- a/src/pat/carousel/carousel.test.js
+++ b/src/pat/carousel/carousel.test.js
@@ -84,5 +84,29 @@ describe("carousel-plugin", function () {
expect(options.autoplaySpeed).toBe(345);
expect(options.adaptiveHeight).toBe(true);
});
+ it("Recalculates the dimensions after images have been loaded.", async () => {
+ $("#lab").html(
+ "
" +
+ " 
" +
+ " 
" +
+ "
"
+ );
+ const carousel = document.querySelector("#lab ul");
+ pattern.init($(carousel));
+ await utils.timeout(20); // wait a bit for all to settle.
+
+ // Initialized immediately, without waiting for images.
+ expect(carousel.classList.contains("slick-initialized")).toBe(true);
+
+ const spy_slick = jest.spyOn($.fn, "slick");
+ const images = carousel.querySelectorAll("img");
+ images[0].dispatchEvent(new Event("load"));
+ images[1].dispatchEvent(new Event("error"));
+ await utils.timeout(150); // debounce
+
+ // Debounced, only called once.
+ expect(spy_slick).toHaveBeenCalledTimes(1);
+ expect(spy_slick).toHaveBeenCalledWith("setPosition");
+ });
});
});
diff --git a/src/pat/equaliser/equaliser.js b/src/pat/equaliser/equaliser.js
index 4b1b23183..a77472ce1 100644
--- a/src/pat/equaliser/equaliser.js
+++ b/src/pat/equaliser/equaliser.js
@@ -17,27 +17,51 @@ var equaliser = {
name: "equaliser",
trigger: ".pat-equaliser, .pat-equalizer",
- async init($el, opts) {
- const ImagesLoaded = (await import("imagesloaded")).default;
-
+ init($el, opts) {
return $el.each(function () {
- var $container = $(this),
- options = parser.parse($container, opts);
+ const container = this;
+ const $container = $(container);
+ const options = parser.parse($container, opts);
$container.data("pat-equaliser", options);
$(window).on(
"resize.pat-equaliser",
null,
- this,
- utils.debounce(equaliser._onEvent, 100)
- );
- ImagesLoaded(
- this,
- $.proxy(function () {
- equaliser._update(this);
- }, this)
+ container,
+ utils.debounce(equaliser._onEvent, 100),
);
- const callback = utils.debounce(equaliser._update.bind(this), 100);
- const observer = new MutationObserver(callback);
+
+ const update = utils.debounce(() => {
+ if (container.isConnected) {
+ equaliser._update(container);
+ }
+ }, 100);
+
+ // Re-equalise when images within the container have been loaded.
+ // The load and error events do not bubble, but can be captured.
+ // This also catches images which are added later.
+ container.addEventListener("load", update, true);
+ container.addEventListener("error", update, true);
+
+ const observer = new MutationObserver((mutations) => {
+ if (!container.isConnected) {
+ // The container was removed from the DOM. Stop observing.
+ observer.disconnect();
+ return;
+ }
+ // Ignore the changes done by any equaliser itself on its
+ // children, otherwise we end up in an infinite loop.
+ const is_relevant = mutations.some(
+ (mutation) =>
+ !(
+ mutation.type === "attributes" &&
+ ["style", "class"].includes(mutation.attributeName) &&
+ $(mutation.target.parentElement).data("pat-equaliser")
+ ),
+ );
+ if (is_relevant) {
+ update();
+ }
+ });
const config = {
childList: true,
subtree: true,
@@ -45,6 +69,8 @@ var equaliser = {
attributes: true,
};
observer.observe(document.body, config);
+
+ equaliser._update(container);
});
},
@@ -77,7 +103,7 @@ var equaliser = {
options.effect.easing,
function () {
$(this).addClass("equalised");
- }
+ },
);
break;
}
diff --git a/src/pat/equaliser/equaliser.test.js b/src/pat/equaliser/equaliser.test.js
index d42666f9a..94d7cf68a 100644
--- a/src/pat/equaliser/equaliser.test.js
+++ b/src/pat/equaliser/equaliser.test.js
@@ -1,5 +1,7 @@
import $ from "jquery";
import pattern from "./equaliser";
+import utils from "../../core/utils";
+import { jest } from "@jest/globals";
describe("pat-equaliser", function () {
beforeEach(function () {
@@ -77,4 +79,97 @@ describe("pat-equaliser", function () {
expect(data.dom).toBe($container[0]);
});
});
+ describe("init", function () {
+ afterEach(function () {
+ jest.restoreAllMocks();
+ });
+
+ it("Equalises on initialization.", function () {
+ document.body.innerHTML = `
+
+ `;
+ const container = document.querySelector(".pat-equaliser");
+ const spy_update = jest.spyOn(pattern, "_update");
+
+ pattern.init($(container));
+
+ expect(spy_update).toHaveBeenCalledTimes(1);
+ expect(spy_update).toHaveBeenCalledWith(container);
+ for (const child of container.children) {
+ expect(child.classList.contains("equalised")).toBe(true);
+ }
+ });
+
+ it("Re-equalises after an image has been loaded or failed loading.", async function () {
+ document.body.innerHTML = `
+
+ `;
+ const container = document.querySelector(".pat-equaliser");
+ pattern.init($(container));
+ await utils.timeout(150); // wait for the debounced observer.
+
+ const spy_update = jest.spyOn(pattern, "_update");
+ const [img1, img2] = container.querySelectorAll("img");
+
+ img1.dispatchEvent(new Event("load"));
+ await utils.timeout(150); // debounce
+ expect(spy_update).toHaveBeenCalledTimes(1);
+ expect(spy_update).toHaveBeenCalledWith(container);
+
+ img2.dispatchEvent(new Event("error"));
+ await utils.timeout(150); // debounce
+ expect(spy_update).toHaveBeenCalledTimes(2);
+ });
+
+ it("Re-equalises when the DOM changes.", async function () {
+ document.body.innerHTML = `
+
+ `;
+ const container = document.querySelector(".pat-equaliser");
+ pattern.init($(container));
+ await utils.timeout(150); // wait for the debounced observer.
+
+ const spy_update = jest.spyOn(pattern, "_update");
+
+ container.children[0].innerHTML = "new content
";
+ await utils.timeout(150); // debounce
+ expect(spy_update).toHaveBeenCalledTimes(1);
+ expect(spy_update).toHaveBeenCalledWith(container);
+ });
+
+ it("Does not re-equalise because of its own changes.", async function () {
+ document.body.innerHTML = `
+
+
+ `;
+ const spy_update = jest.spyOn(pattern, "_update");
+ pattern.init($(".pat-equaliser"));
+ // Initial update for both.
+ expect(spy_update).toHaveBeenCalledTimes(2);
+
+ await utils.timeout(500);
+ // No further updates.
+ expect(spy_update).toHaveBeenCalledTimes(2);
+ });
+ });
});
diff --git a/src/pat/masonry/documentation.md b/src/pat/masonry/documentation.md
index a0731c736..d2bd1502e 100644
--- a/src/pat/masonry/documentation.md
+++ b/src/pat/masonry/documentation.md
@@ -8,6 +8,17 @@ fitting stones in a wall. You’ve probably seen it in use all over the Internet
## Documentation
+### Images and the `masonry-ready` class
+
+The layout is updated whenever an image within the masonry container has been
+loaded or failed loading - also for images which are added later.
+When all initially present images are loaded, the class `masonry-ready` is set
+on the container. The default styles hide the items until then.
+
+Images with `loading="lazy"` are not waited for, as they might only be loaded
+when scrolled into view. Set the `width` and `height` attributes on such images
+to avoid layout shifts.
+
### Options reference
| Property | Default Value | Description |
diff --git a/src/pat/masonry/masonry.js b/src/pat/masonry/masonry.js
index 4de191d19..1c4742e24 100644
--- a/src/pat/masonry/masonry.js
+++ b/src/pat/masonry/masonry.js
@@ -43,31 +43,24 @@ export default Base.extend({
async init($el, opts) {
Masonry = (await import("masonry-layout")).default;
- const ImagesLoaded = (await import("imagesloaded")).default;
this.options = parser.parse(this.$el, opts);
// Initialize
this.initMasonry();
- const imgLoad = await ImagesLoaded(this.$el);
- imgLoad.on(
- "progress",
- function () {
- if (!this.msnry) {
- this.initMasonry();
- }
- this.quicklayout();
- }.bind(this)
- );
- imgLoad.on(
- "always",
- function () {
- if (!this.msnry) {
- this.initMasonry();
- }
- this.layout();
- }.bind(this)
- );
+ // Re-layout whenever an image within has been loaded or failed
+ // loading. The load and error events do not bubble, but can be
+ // captured. This also catches images which are added later.
+ // When all images are loaded, do a full layout which sets the
+ // ``masonry-ready`` class.
+ this.is_images_loaded = false;
+ const on_image_loaded = () => {
+ this.quicklayout();
+ this.layout_when_images_loaded();
+ };
+ this.el.addEventListener("load", on_image_loaded, true);
+ this.el.addEventListener("error", on_image_loaded, true);
+ this.layout_when_images_loaded();
// Update if something gets injected inside the pat-masonry
this.$el
@@ -140,16 +133,30 @@ export default Base.extend({
layout: function () {
this.$el.removeClass("masonry-ready");
- this.msnry.on(
- "layoutComplete",
- function () {
- this.$el.addClass("masonry-ready");
- }.bind(this)
- );
+ this.msnry.once("layoutComplete", () => {
+ this.$el.addClass("masonry-ready");
+ });
this.msnry.layout();
this.quicklayout();
},
+ layout_when_images_loaded() {
+ // Do a full layout once all images are loaded or failed loading.
+ if (this.is_images_loaded) {
+ return;
+ }
+ // Ignore lazy loading images, which might only be loaded when
+ // scrolled into view.
+ const is_images_loaded = [...this.el.querySelectorAll("img")].every(
+ (img) => img.complete || img.getAttribute("loading") === "lazy"
+ );
+ if (!is_images_loaded) {
+ return;
+ }
+ this.is_images_loaded = true;
+ this.layout();
+ },
+
getTypeCastedValue: function (original) {
var val = Number(original);
return isNaN(val) ? original || 0 : val;
diff --git a/src/pat/masonry/masonry.test.js b/src/pat/masonry/masonry.test.js
index c4dc3642f..e5e56b2ad 100644
--- a/src/pat/masonry/masonry.test.js
+++ b/src/pat/masonry/masonry.test.js
@@ -1,32 +1,100 @@
import pattern from "./masonry";
-import $ from "jquery";
+import events from "../../core/events";
+import { jest } from "@jest/globals";
+
+const set_complete = (img) => {
+ // jsdom does not load images. Mark them as loaded.
+ Object.defineProperty(img, "complete", { value: true });
+};
describe("pat-masonry", function () {
- beforeEach(function () {
- $("", { id: "lab" }).appendTo(document.body);
- });
afterEach(function () {
- $("#lab").remove();
+ document.body.innerHTML = "";
+ jest.restoreAllMocks();
+ });
+
+ it("Sets class masonry-ready on the element after masonry has finished", async function () {
+ document.body.innerHTML = `
+
+ `;
+ const el = document.querySelector(".pat-masonry");
+ expect(el.classList.contains("masonry-ready")).toBe(false);
+
+ const instance = pattern.init(el);
+ await events.await_pattern_init(instance);
+
+ expect(el.classList.contains("masonry-ready")).toBe(true);
+ });
+
+ it("Waits for all images to be loaded before setting masonry-ready", async function () {
+ document.body.innerHTML = `
+
+ `;
+ const el = document.querySelector(".pat-masonry");
+ const [img1, img2] = el.querySelectorAll("img");
+
+ const instance = pattern.init(el);
+ await events.await_pattern_init(instance);
+ const spy_quicklayout = jest.spyOn(instance, "quicklayout");
+ const spy_layout = jest.spyOn(instance, "layout");
+
+ expect(el.classList.contains("masonry-ready")).toBe(false);
+
+ // First image loaded - quick re-layout, but not ready yet.
+ set_complete(img1);
+ img1.dispatchEvent(new Event("load"));
+ expect(spy_quicklayout).toHaveBeenCalled();
+ expect(spy_layout).not.toHaveBeenCalled();
+ expect(el.classList.contains("masonry-ready")).toBe(false);
+
+ // Second image failed loading - full layout and ready.
+ set_complete(img2);
+ img2.dispatchEvent(new Event("error"));
+ expect(spy_layout).toHaveBeenCalledTimes(1);
+ expect(el.classList.contains("masonry-ready")).toBe(true);
+
+ // Images loaded later only lead to a quick re-layout.
+ spy_quicklayout.mockClear();
+ img1.dispatchEvent(new Event("load"));
+ expect(spy_quicklayout).toHaveBeenCalledTimes(1);
+ expect(spy_layout).toHaveBeenCalledTimes(1);
+ });
+
+ it("Does not wait for lazy loading images", async function () {
+ document.body.innerHTML = `
+
+ `;
+ const el = document.querySelector(".pat-masonry");
+
+ const instance = pattern.init(el);
+ await events.await_pattern_init(instance);
+
+ expect(el.classList.contains("masonry-ready")).toBe(true);
});
- it("Sets class masonry-ready on the element after masonry has finished", function () {
- var $msnry;
- $("#lab").html(
- "" +
- "
" +
- "

" +
- "
" +
- "
" +
- "

" +
- "
" +
- "
"
- );
- $msnry = $("#lab .pat-masonry");
- expect($msnry.hasClass("masonry-ready")).toBeFalsy();
- pattern.init($msnry);
- setTimeout(function () {
- // XXX: Reenable when pattern.init returns a promise
- // expect($msnry.hasClass("masonry-ready")).toBeTruthy();
- }, 2000);
+ it("Does not accumulate layoutComplete event listeners", async function () {
+ document.body.innerHTML = `
+
+ `;
+ const el = document.querySelector(".pat-masonry");
+
+ const instance = pattern.init(el);
+ await events.await_pattern_init(instance);
+
+ instance.layout();
+ instance.layout();
+ instance.layout();
+
+ expect(instance.msnry._events?.layoutComplete?.length || 0).toBe(0);
});
});
diff --git a/src/pat/scroll/scroll.js b/src/pat/scroll/scroll.js
index 7e8c248ab..1f5823192 100644
--- a/src/pat/scroll/scroll.js
+++ b/src/pat/scroll/scroll.js
@@ -23,14 +23,20 @@ class Pattern extends BasePattern {
parser_group_options = false;
- async init() {
+ init() {
if (this.options.delay) {
this.options.delay = utils.parseTime(this.options.delay);
}
if (this.options.trigger === "auto") {
- const ImagesLoaded = (await import("imagesloaded")).default;
- // Only calculate the offset when all images are loaded
- ImagesLoaded(document.body, this.scrollTo.bind(this));
+ // Only calculate the offset when the page including all images
+ // is loaded.
+ if (document.readyState === "complete") {
+ this.scrollTo();
+ } else {
+ window.addEventListener("load", () => this.scrollTo(), {
+ once: true,
+ });
+ }
}
if (this.options.trigger === "auto" || this.options.trigger === "click") {
this.el.addEventListener("click", this.scrollTo.bind(this));
diff --git a/src/pat/scroll/scroll.test.js b/src/pat/scroll/scroll.test.js
index 9916f9549..4dff3fe20 100644
--- a/src/pat/scroll/scroll.test.js
+++ b/src/pat/scroll/scroll.test.js
@@ -34,6 +34,37 @@ describe("pat-scroll", function () {
expect(this.spy_scrollTo).toHaveBeenCalledTimes(2);
});
+ it("1.1 - with trigger 'auto' waits for the page to be loaded before scrolling", async function () {
+ const spy_ready_state = jest
+ .spyOn(document, "readyState", "get")
+ .mockReturnValue("interactive");
+
+ document.body.innerHTML = `
+ p1
+
+ `;
+ const el = document.querySelector(".pat-scroll");
+
+ const instance = new Pattern(el);
+ await events.await_pattern_init(instance);
+ await utils.timeout(1); // wait a tick for async to settle.
+
+ // Page not loaded yet - no scrolling.
+ expect(this.spy_scrollTo).toHaveBeenCalledTimes(0);
+
+ spy_ready_state.mockReturnValue("complete");
+ window.dispatchEvent(new Event("load"));
+ await utils.timeout(1); // wait a tick for async to settle.
+
+ expect(this.spy_scrollTo).toHaveBeenCalledTimes(1);
+
+ // Only once.
+ window.dispatchEvent(new Event("load"));
+ await utils.timeout(1); // wait a tick for async to settle.
+
+ expect(this.spy_scrollTo).toHaveBeenCalledTimes(1);
+ });
+
it("2 - will scroll to an anchor on click if the trigger is set to 'click'", async function () {
document.body.innerHTML = `
p1
diff --git a/src/pat/validation/validation.js b/src/pat/validation/validation.js
index 7165e17ff..7a92a0dc7 100644
--- a/src/pat/validation/validation.js
+++ b/src/pat/validation/validation.js
@@ -59,7 +59,7 @@ class Pattern extends BasePattern {
// Make sure this event handler is run early, in the capturing
// phase in order to be able to cancel later non-capturing submit
// events.
- { capture: true }
+ { capture: true },
);
this.initialize_inputs();
@@ -91,19 +91,19 @@ class Pattern extends BasePattern {
input,
"input",
`pat-validation--input-${input.name}--${cnt}--validator`,
- (e) => debouncer(e)
+ (e) => debouncer(e),
);
events.add_event_listener(
input,
"change",
`pat-validation--change-${input.name}--${cnt}--validator`,
- (e) => debouncer(e)
+ (e) => debouncer(e),
);
events.add_event_listener(
input,
"blur",
`pat-validation--blur-${input.name}--${cnt}--validator`,
- (e) => debouncer(e)
+ (e) => debouncer(e),
);
}
}
@@ -202,7 +202,7 @@ class Pattern extends BasePattern {
// with a single space.
msg_attr = not_after_el?.labels?.[0]?.textContent.replace(
/\s\s+/g, // replace all whitespace
- " " // with a single space
+ " ", // with a single space
);
msg_attr = msg_attr || not_after_el.name;
}
@@ -223,7 +223,7 @@ class Pattern extends BasePattern {
// with a single space.
msg_attr = not_before_el?.labels?.[0]?.textContent.replace(
/\s\s+/g, // replace all whitespace
- " " // with a single space
+ " ", // with a single space
);
msg_attr = msg_attr || not_before_el.name;
}
@@ -400,11 +400,11 @@ class Pattern extends BasePattern {
// executed within the web page context.
const dompurify = (await import("dompurify")).default;
const validation_message = dompurify.sanitize(
- input.validationMessage || input[KEY_ERROR_MSG]
+ input.validationMessage || input[KEY_ERROR_MSG],
);
const error_node = dom.create_from_string(
- this.error_template(validation_message)
+ this.error_template(validation_message),
).firstChild;
let fieldset;
diff --git a/src/pat/validation/validation.test.js b/src/pat/validation/validation.test.js
index 4f34fe9d1..9df289f41 100644
--- a/src/pat/validation/validation.test.js
+++ b/src/pat/validation/validation.test.js
@@ -205,7 +205,7 @@ describe("pat-validation", function () {
await utils.timeout(1); // wait a tick for async to settle.
expect(el.querySelectorAll("em.warning").length).toBe(1);
expect(el.querySelectorAll("em.warning")[0].textContent).toBe(
- "This value must be an integer."
+ "This value must be an integer.",
);
expect(el.querySelector("#form-buttons-create").disabled).toBe(true);
@@ -240,7 +240,7 @@ describe("pat-validation", function () {
await utils.timeout(1); // wait a tick for async to settle.
expect(el.querySelectorAll("div.validation-error").length).toBe(1);
expect(el.querySelectorAll("div.validation-error")[0].textContent).toBe(
- "need this"
+ "need this",
);
});
@@ -636,7 +636,7 @@ describe("pat-validation", function () {
expect(el.querySelectorAll("em.warning").length).toBe(1);
expect(el.querySelector("em.warning").textContent).toBe(
- "I'm sorry Dave, I can't let you do that."
+ "I'm sorry Dave, I can't let you do that.",
);
});
@@ -683,7 +683,7 @@ describe("pat-validation", function () {
expect(el.querySelectorAll("em.warning").length).toBe(1);
expect(el.querySelector("em.warning").textContent).toBe(
- "This value must be a valid email address."
+ "This value must be a valid email address.",
);
inp.value = "person@mail.com";
@@ -721,7 +721,7 @@ describe("pat-validation", function () {
expect(el.querySelectorAll("em.warning").length).toBe(1);
expect(el.querySelector("em.warning").textContent).toBe(
- "This value must be greater than or equal to 5"
+ "This value must be greater than or equal to 5",
);
inp_min.value = 6;
@@ -738,7 +738,7 @@ describe("pat-validation", function () {
expect(el.querySelectorAll("em.warning").length).toBe(1);
expect(el.querySelector("em.warning").textContent).toBe(
- "This value must be less than or equal to 5"
+ "This value must be less than or equal to 5",
);
inp_max.value = 5;
@@ -861,7 +861,7 @@ describe("pat-validation", function () {
expect(el.querySelectorAll("em.warning").length).toBe(1);
expect(el.querySelectorAll("em.warning")[0].textContent).toBe(
- "The value must be an integer."
+ "The value must be an integer.",
);
inp.value = 5;
@@ -891,7 +891,7 @@ describe("pat-validation", function () {
expect(el.querySelectorAll("em.warning").length).toBe(1);
expect(el.querySelectorAll("em.warning")[0].textContent).toBe(
- "The value must be an integer."
+ "The value must be an integer.",
);
inp.value = 5;
@@ -1075,7 +1075,7 @@ describe("pat-validation", function () {
await utils.timeout(1); // wait a tick for async to settle.
expect(el.querySelectorAll("em.warning").length).toBe(1);
expect(el.querySelectorAll("em.warning")[0].textContent).toBe(
- "The date must be after 2011-11-11"
+ "The date must be after 2011-11-11",
);
inp.value = "2023-02-23";
@@ -1083,7 +1083,7 @@ describe("pat-validation", function () {
await utils.timeout(1); // wait a tick for async to settle.
expect(el.querySelectorAll("em.warning").length).toBe(1);
expect(el.querySelectorAll("em.warning")[0].textContent).toBe(
- "The date must be before 2022-02-22"
+ "The date must be before 2022-02-22",
);
inp.value = "2022-01-01";
@@ -1130,11 +1130,11 @@ describe("pat-validation", function () {
expect(el.querySelectorAll("em.warning").length).toBe(2);
expect(el.querySelectorAll("em.warning")[0].textContent).toBe(
- "The date must be before woo date"
+ "The date must be before woo date",
);
expect(el.querySelectorAll("em.warning")[1].textContent).toBe(
- "The date must be after ye date"
+ "The date must be after ye date",
);
});
@@ -1171,11 +1171,11 @@ describe("pat-validation", function () {
expect(el.querySelectorAll("em.warning").length).toBe(2);
expect(el.querySelectorAll("em.warning")[0].textContent).toBe(
- "The date must be before date2"
+ "The date must be before date2",
);
expect(el.querySelectorAll("em.warning")[1].textContent).toBe(
- "The date must be after date1"
+ "The date must be after date1",
);
});
@@ -1221,10 +1221,10 @@ describe("pat-validation", function () {
await utils.timeout(1); // wait a tick for async to settle.
expect(el.querySelectorAll("em.warning").length).toBe(2);
expect(el.querySelectorAll("em.warning")[0].textContent).toBe(
- "The start date must on or before the end date."
+ "The start date must on or before the end date.",
);
expect(el.querySelectorAll("em.warning")[1].textContent).toBe(
- "The end date must on or before the start date."
+ "The end date must on or before the start date.",
);
// Fulfill the before/after constraint - same date
@@ -1241,10 +1241,10 @@ describe("pat-validation", function () {
await utils.timeout(1); // wait a tick for async to settle.
expect(el.querySelectorAll("em.warning").length).toBe(2);
expect(el.querySelectorAll("em.warning")[0].textContent).toBe(
- "The start date must on or before the end date."
+ "The start date must on or before the end date.",
);
expect(el.querySelectorAll("em.warning")[1].textContent).toBe(
- "The end date must on or before the start date."
+ "The end date must on or before the start date.",
);
// Fulfill the before/after constraint - start before end
@@ -1315,7 +1315,7 @@ describe("pat-validation", function () {
expect(el.querySelectorAll("em.warning").length).toBe(1);
expect(el.querySelectorAll("em.warning")[0].textContent).toBe(
- "This field is required"
+ "This field is required",
);
});
@@ -1361,10 +1361,10 @@ describe("pat-validation", function () {
await utils.timeout(1); // wait a tick for async to settle.
expect(el.querySelectorAll("em.warning").length).toBe(2);
expect(el.querySelectorAll("em.warning")[0].textContent).toBe(
- "The start date/time must on or before the end date/time."
+ "The start date/time must on or before the end date/time.",
);
expect(el.querySelectorAll("em.warning")[1].textContent).toBe(
- "The end date/time must on or before the start date/time."
+ "The end date/time must on or before the start date/time.",
);
// Fulfill the before/after constraint - same date
@@ -1381,10 +1381,10 @@ describe("pat-validation", function () {
await utils.timeout(1); // wait a tick for async to settle.
expect(el.querySelectorAll("em.warning").length).toBe(2);
expect(el.querySelectorAll("em.warning")[0].textContent).toBe(
- "The start date/time must on or before the end date/time."
+ "The start date/time must on or before the end date/time.",
);
expect(el.querySelectorAll("em.warning")[1].textContent).toBe(
- "The end date/time must on or before the start date/time."
+ "The end date/time must on or before the start date/time.",
);
// Fulfill the before/after constraint - start before end
@@ -1453,7 +1453,7 @@ describe("pat-validation", function () {
expect(el.querySelectorAll("em.warning").length).toBe(1);
expect(el.querySelectorAll("em.warning")[0].textContent).toBe(
- "This field is required"
+ "This field is required",
);
inps[0].checked = true;
@@ -1499,7 +1499,7 @@ describe("pat-validation", function () {
await utils.timeout(1); // wait a tick for async to settle.
expect(el.querySelectorAll("em.warning").length).toBe(1);
expect(el.querySelectorAll("em.warning")[0].textContent).toBe(
- "I would like this to be equal to password"
+ "I would like this to be equal to password",
);
expect(el.querySelector("#form-buttons-create").disabled).toBe(true);
@@ -1623,7 +1623,7 @@ describe("pat-validation", function () {
// The text content should contain the message without HTML tags
expect(warning_text).toContain(
- "This field is required and must be filled out."
+ "This field is required and must be filled out.",
);
// The innerHTML should contain the safe HTML (DOMPurify allows by default)