@getforma/core 1.0.9 → 1.0.10

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/dist/runtime.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { reconcileList } from './chunk-AFRFF7XL.js';
2
+ import { isEventHandlerAttr, isUrlAttr, isDangerousUrl } from './chunk-2QQBKQIF.js';
2
3
  import { internalEffect, batch } from './chunk-3G7ET4O5.js';
3
4
  import { createSignal, createComputed } from './chunk-HLM5BZZQ.js';
4
5
 
@@ -333,6 +334,11 @@ function createReconciler(config) {
333
334
  }
334
335
 
335
336
  // src/runtime.ts
337
+ function isUnsafeAttrBinding(name, value) {
338
+ if (isEventHandlerAttr(name)) return true;
339
+ if (isUrlAttr(name) && isDangerousUrl(value)) return true;
340
+ return false;
341
+ }
336
342
  var _refetchRegistry = /* @__PURE__ */ new Map();
337
343
  function $refetch(id) {
338
344
  const fn = _refetchRegistry.get(id);
@@ -1335,7 +1341,12 @@ function cloneAttributeTemplates(el, item) {
1335
1341
  if (attr.value.includes("{item")) {
1336
1342
  const compiled = compileTemplate(attr.value);
1337
1343
  entries.push({ attr: attr.name, compiled });
1338
- node.setAttribute(attr.name, evaluateCompiledTemplate(compiled, item));
1344
+ const value = evaluateCompiledTemplate(compiled, item);
1345
+ if (isUnsafeAttrBinding(attr.name, value)) {
1346
+ node.removeAttribute(attr.name);
1347
+ } else {
1348
+ node.setAttribute(attr.name, value);
1349
+ }
1339
1350
  }
1340
1351
  }
1341
1352
  if (entries.length > 0) {
@@ -2177,7 +2188,12 @@ function bindElement(el, scope, disposers) {
2177
2188
  if (val == null || val === false) {
2178
2189
  el.removeAttribute(attrName);
2179
2190
  } else {
2180
- el.setAttribute(attrName, String(val));
2191
+ const str = String(val);
2192
+ if (isUnsafeAttrBinding(attrName, str)) {
2193
+ el.removeAttribute(attrName);
2194
+ } else {
2195
+ el.setAttribute(attrName, str);
2196
+ }
2181
2197
  }
2182
2198
  });
2183
2199
  disposers.push(dispose);