vanduo-framework 1.1.8 → 1.2.0

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.
@@ -1,3 +1,5 @@
1
+ 'use strict';
2
+
1
3
  /**
2
4
  * Vanduo Framework - Utility Helpers
3
5
  * Common utility functions used across the framework
@@ -86,7 +88,11 @@ function on(target, event, handlerOrSelector, handler) {
86
88
  element.addEventListener(event, function (e) {
87
89
  const delegateTarget = e.target.closest(handlerOrSelector);
88
90
  if (delegateTarget && element.contains(delegateTarget)) {
89
- handler.call(delegateTarget, e);
91
+ try {
92
+ handler.call(delegateTarget, e);
93
+ } catch (error) {
94
+ console.warn('[Vanduo Helpers] Delegated handler error:', error);
95
+ }
90
96
  }
91
97
  });
92
98
  }
@@ -238,7 +244,7 @@ function getPosition(element) {
238
244
  */
239
245
  function escapeHtml(str) {
240
246
  if (!str) return '';
241
- var div = document.createElement('div');
247
+ const div = document.createElement('div');
242
248
  div.appendChild(document.createTextNode(str));
243
249
  return div.innerHTML;
244
250
  }
@@ -252,24 +258,30 @@ function escapeHtml(str) {
252
258
  */
253
259
  function sanitizeHtml(input) {
254
260
  if (!input) return '';
255
- var doc = new DOMParser().parseFromString(input, 'text/html');
256
- var allowed = ['B', 'STRONG', 'I', 'EM', 'BR', 'A', 'SPAN', 'U', 'SVG', 'PATH', 'LINE', 'CIRCLE', 'POLYLINE', 'RECT', 'G'];
261
+ let doc;
262
+ try {
263
+ doc = new DOMParser().parseFromString(input, 'text/html');
264
+ } catch (_error) {
265
+ // Fail closed to plain escaped text if parser is unavailable/fails.
266
+ return escapeHtml(input);
267
+ }
268
+ const allowed = ['B', 'STRONG', 'I', 'EM', 'BR', 'A', 'SPAN', 'U', 'SVG', 'PATH', 'LINE', 'CIRCLE', 'POLYLINE', 'RECT', 'G'];
257
269
 
258
- var sanitizeNode = function (node) {
259
- var children = Array.from(node.childNodes);
270
+ const sanitizeNode = function (node) {
271
+ const children = Array.from(node.childNodes);
260
272
  children.forEach(function (child) {
261
273
  if (child.nodeType === Node.TEXT_NODE) return;
262
274
 
263
275
  if (!allowed.includes(child.nodeName)) {
264
- var text = document.createTextNode(child.textContent);
276
+ const text = document.createTextNode(child.textContent);
265
277
  node.replaceChild(text, child);
266
278
  return;
267
279
  }
268
280
 
269
281
  if (child.nodeName === 'A') {
270
- var href = child.getAttribute('href') || '';
282
+ const href = child.getAttribute('href') || '';
271
283
  try {
272
- var url = new URL(href, location.href);
284
+ const url = new URL(href, location.href);
273
285
  if (!['http:', 'https:', 'mailto:'].includes(url.protocol)) {
274
286
  child.removeAttribute('href');
275
287
  }
@@ -280,17 +292,17 @@ function sanitizeHtml(input) {
280
292
  child.removeAttribute('rel');
281
293
  } else if (child.nodeName === 'SVG' || child.closest && child.closest('svg')) {
282
294
  // Allow safe SVG presentation attributes only
283
- var safeSvgAttrs = ['xmlns', 'width', 'height', 'viewBox', 'fill', 'stroke', 'stroke-width',
295
+ const safeSvgAttrs = ['xmlns', 'width', 'height', 'viewBox', 'fill', 'stroke', 'stroke-width',
284
296
  'stroke-linecap', 'stroke-linejoin', 'd', 'cx', 'cy', 'r', 'x1', 'y1', 'x2', 'y2', 'points',
285
297
  'transform', 'class'];
286
- var attrs = Array.from(child.attributes || []);
298
+ const attrs = Array.from(child.attributes || []);
287
299
  attrs.forEach(function (a) {
288
300
  if (!safeSvgAttrs.includes(a.name)) {
289
301
  child.removeAttribute(a.name);
290
302
  }
291
303
  });
292
304
  } else {
293
- var otherAttrs = Array.from(child.attributes || []);
305
+ const otherAttrs = Array.from(child.attributes || []);
294
306
  otherAttrs.forEach(function (a) { child.removeAttribute(a.name); });
295
307
  }
296
308
 
package/js/vanduo.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Vanduo Framework - Main JavaScript File
3
- * v1.1.6
3
+ * v1.2.0
4
4
  */
5
5
 
6
6
  (function() {
@@ -10,7 +10,7 @@
10
10
  * Vanduo Framework Object
11
11
  */
12
12
  const Vanduo = {
13
- version: '1.1.6',
13
+ version: '1.2.0',
14
14
  components: {},
15
15
 
16
16
  /**
@@ -51,7 +51,7 @@
51
51
  }
52
52
  });
53
53
 
54
- console.log('Vanduo Framework v1.1.6 initialized');
54
+ console.log('Vanduo Framework v1.2.0 initialized');
55
55
  },
56
56
 
57
57
  /**
@@ -70,7 +70,7 @@
70
70
  * @param {string} name - Component name
71
71
  */
72
72
  reinit: function(name) {
73
- var component = this.components[name];
73
+ const component = this.components[name];
74
74
  if (component && component.init && typeof component.init === 'function') {
75
75
  try {
76
76
  component.init();
@@ -86,9 +86,9 @@
86
86
  */
87
87
  destroyAll: function() {
88
88
  // First, destroy components that have their own destroyAll
89
- var names = Object.keys(this.components);
90
- for (var i = 0; i < names.length; i++) {
91
- var component = this.components[names[i]];
89
+ const names = Object.keys(this.components);
90
+ for (let i = 0; i < names.length; i++) {
91
+ const component = this.components[names[i]];
92
92
  if (component && component.destroyAll && typeof component.destroyAll === 'function') {
93
93
  try {
94
94
  component.destroyAll();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vanduo-framework",
3
- "version": "1.1.8",
3
+ "version": "1.2.0",
4
4
  "description": "Zero-dependency CSS/JS framework built on Fibonacci/Golden Ratio design system with Open Color integration",
5
5
  "keywords": [
6
6
  "css",