From b894f3153f7ec528711a491e3add6b97c9df5f1c Mon Sep 17 00:00:00 2001 From: "Nick.Brigden" Date: Tue, 26 Aug 2025 08:40:13 +0100 Subject: [PATCH 1/2] Added capture for icon-anchor and div-icon style --- src/l-div-icon.js | 4 ++++ src/l-div-icon.test.js | 3 ++- src/l-geojson.js | 4 ++++ src/l-geojson.test.js | 31 +++++++++++++++++++++++++++++++ 4 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 src/l-geojson.test.js diff --git a/src/l-div-icon.js b/src/l-div-icon.js index 2880b67..d234314 100644 --- a/src/l-div-icon.js +++ b/src/l-div-icon.js @@ -16,6 +16,10 @@ export default class CustomElement extends HTMLElement { if (className !== null) { options["className"] = className; } + const iconAnchor = this.getAttribute("icon-anchor"); + if (iconAnchor !== null) { + options["iconAnchor"] = iconAnchor; + } this.icon = divIcon(options); this.dispatchEvent( diff --git a/src/l-div-icon.test.js b/src/l-div-icon.test.js index e152bd6..53c8e1f 100644 --- a/src/l-div-icon.test.js +++ b/src/l-div-icon.test.js @@ -6,9 +6,10 @@ import "./index.js"; it("should render a div icon", () => { const el = document.createElement("l-div-icon"); el.innerHTML = "Hello, World!"; + el.setAttribute("icon-anchor","[50, 50]"); document.body.appendChild(el); expect(el.icon).toBeInstanceOf(DivIcon); - expect(el.icon).toEqual(divIcon({ html: "Hello, World!" })); + expect(el.icon).toEqual(divIcon({ html: "Hello, World!" , iconAnchor: "[50, 50]"})); }); it("should attach div icon to marker", () => { diff --git a/src/l-geojson.js b/src/l-geojson.js index c3faf73..f6d499f 100644 --- a/src/l-geojson.js +++ b/src/l-geojson.js @@ -17,6 +17,10 @@ class LGeoJSON extends HTMLElement { if (pane !== null) { options["pane"] = pane.getAttribute("name"); } + const style = this.getAttribute("style"); + if (style !== null) { + options["style"] = JSON.parse(style) + } if (value !== null) { this.layer = geoJSON(JSON.parse(value), options); diff --git a/src/l-geojson.test.js b/src/l-geojson.test.js new file mode 100644 index 0000000..94962bc --- /dev/null +++ b/src/l-geojson.test.js @@ -0,0 +1,31 @@ +// @vitest-environment happy-dom +import { geoJson } from "leaflet"; +import { it, expect } from "vitest"; +import "./index.js"; +import { layerConnected } from "./events.js"; + +it("should render a geoJson object", async () => { + const el = document.createElement("l-geojson"); + el.setAttribute("geojson", "[[50, 0], [50, -1], [49, -1], [49,0]]"); + el.setAttribute("id", "test-layer"); + el.setAttribute("style", '{"color": "#0000ff"}'); + let promise = new Promise((resolve) => { + el.addEventListener(layerConnected, (ev) => { + resolve(ev.detail); + }); + }); + document.body.appendChild(el); + const actual = await promise; + const expected = { + layer: geoJson( + [ + [50, 0], + [50, -1], + [49, -1], + [49, 0], + ], + { style: { color: "#0000ff" } }, + ) + }; + expect(actual).toEqual(expected); +}); From d138d013b03576294a8df7224934167bb06a45c3 Mon Sep 17 00:00:00 2001 From: andrewgryan Date: Fri, 29 Aug 2025 11:42:29 +0100 Subject: [PATCH 2/2] Release 0.13.10 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2ccb0b1..ecf44f0 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "leaflet-html", "type": "module", - "version": "0.13.9", + "version": "0.13.10", "description": "Leaflet maps expressed in HTML suitable for HTMX", "keywords": [ "leaflet",