@hortonstudio/main 1.9.2 → 1.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/autoInit/site-settings.js +26 -1
- package/package.json +1 -1
|
@@ -21,8 +21,33 @@ export function init() {
|
|
|
21
21
|
const settingElements = list.querySelectorAll('[data-site-settings]');
|
|
22
22
|
|
|
23
23
|
settingElements.forEach(element => {
|
|
24
|
+
// Clone the element to avoid modifying the original DOM
|
|
25
|
+
const clonedElement = element.cloneNode(true);
|
|
26
|
+
|
|
27
|
+
// Find and remove elements with data-site-settings-hide that match their classes
|
|
28
|
+
const hideElements = clonedElement.querySelectorAll('[data-site-settings-hide]');
|
|
29
|
+
|
|
30
|
+
hideElements.forEach(hideElement => {
|
|
31
|
+
const hideValue = hideElement.getAttribute('data-site-settings-hide');
|
|
32
|
+
|
|
33
|
+
if (hideValue) {
|
|
34
|
+
// Split by spaces to get all class names to check
|
|
35
|
+
const classesToHide = hideValue.split(' ').filter(c => c.trim());
|
|
36
|
+
|
|
37
|
+
// Check if element has any of the classes
|
|
38
|
+
const hasMatchingClass = classesToHide.some(className =>
|
|
39
|
+
hideElement.classList.contains(className)
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
// Remove element if it has a matching class
|
|
43
|
+
if (hasMatchingClass) {
|
|
44
|
+
hideElement.remove();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
|
|
24
49
|
const settingName = element.getAttribute('data-site-settings');
|
|
25
|
-
const settingValue =
|
|
50
|
+
const settingValue = clonedElement.textContent.trim();
|
|
26
51
|
|
|
27
52
|
// Only store if both name and value exist (ignore empty elements like images)
|
|
28
53
|
if (settingName && settingValue) {
|