@unsetsoft/ryunixjs 1.2.4-canary.1 → 1.2.4-canary.2
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/Ryunix.esm.js +1 -125
- package/dist/Ryunix.esm.js.map +1 -1
- package/dist/Ryunix.umd.js +1 -125
- package/dist/Ryunix.umd.js.map +1 -1
- package/dist/Ryunix.umd.min.js +1 -1
- package/dist/Ryunix.umd.min.js.map +1 -1
- package/package.json +1 -1
package/dist/Ryunix.esm.js
CHANGED
|
@@ -56,17 +56,6 @@ const EFFECT_TAGS = Object.freeze({
|
|
|
56
56
|
NO_EFFECT: Symbol.for('ryunix.reconciler.status.no_effect'),
|
|
57
57
|
});
|
|
58
58
|
|
|
59
|
-
const DANGEROUSLY_SET_INNER_HTML = 'dangerousInjection';
|
|
60
|
-
|
|
61
|
-
const DANGEROUS_PROPERTIES = Object.freeze([
|
|
62
|
-
'innerHTML',
|
|
63
|
-
'outerHTML',
|
|
64
|
-
'insertAdjacentHTML',
|
|
65
|
-
'insertAdjacentText',
|
|
66
|
-
'insertAdjacentElement',
|
|
67
|
-
'setHTML',
|
|
68
|
-
]);
|
|
69
|
-
|
|
70
59
|
/**
|
|
71
60
|
* Type checking utilities
|
|
72
61
|
*/
|
|
@@ -280,71 +269,6 @@ const runEffects = (fiber) => {
|
|
|
280
269
|
}
|
|
281
270
|
};
|
|
282
271
|
|
|
283
|
-
/**
|
|
284
|
-
* Checks if a property is dangerous and should be blocked
|
|
285
|
-
* @param {string} propName - Property name
|
|
286
|
-
* @returns {boolean} True if the property is dangerous
|
|
287
|
-
*/
|
|
288
|
-
const isDangerousProperty = (propName) => {
|
|
289
|
-
return DANGEROUS_PROPERTIES.includes(propName)
|
|
290
|
-
};
|
|
291
|
-
|
|
292
|
-
/**
|
|
293
|
-
* Validates and applies DANGEROUSLY_SET_INNER_HTML safely
|
|
294
|
-
* @param {HTMLElement} dom - DOM element
|
|
295
|
-
* @param {Object} DANGEROUSLY_SET_INNER_HTML - Object with __html property
|
|
296
|
-
*/
|
|
297
|
-
const applyDangerouslySetInnerHTML = (dom, dangerousInjection) => {
|
|
298
|
-
if (!is.object(dangerousInjection)) {
|
|
299
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
300
|
-
console.warn(
|
|
301
|
-
`${DANGEROUSLY_SET_INNER_HTML} must be an object with the __html property`,
|
|
302
|
-
);
|
|
303
|
-
}
|
|
304
|
-
return
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
if (!('__html' in dangerousInjection)) {
|
|
308
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
309
|
-
console.warn(
|
|
310
|
-
`${DANGEROUSLY_SET_INNER_HTML} must have the __html property`,
|
|
311
|
-
);
|
|
312
|
-
}
|
|
313
|
-
return
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
const html = dangerousInjection.__html;
|
|
317
|
-
|
|
318
|
-
if (html == null) {
|
|
319
|
-
dom.innerHTML = '';
|
|
320
|
-
return
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
if (typeof html !== 'string') {
|
|
324
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
325
|
-
console.warn(`${DANGEROUSLY_SET_INNER_HTML}.__html must be a string`);
|
|
326
|
-
}
|
|
327
|
-
return
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
// Warning in development
|
|
331
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
332
|
-
console.warn(
|
|
333
|
-
`⚠️ WARNING: You are using ${DANGEROUSLY_SET_INNER_HTML}. ` +
|
|
334
|
-
'This can expose your application to XSS attacks if the content is not sanitized. ' +
|
|
335
|
-
'Make sure you trust the source of the HTML before using it.',
|
|
336
|
-
);
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
try {
|
|
340
|
-
dom.innerHTML = html;
|
|
341
|
-
} catch (error) {
|
|
342
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
343
|
-
console.error('Error setting innerHTML:', error);
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
};
|
|
347
|
-
|
|
348
272
|
/**
|
|
349
273
|
* Convert camelCase to kebab-case for CSS properties
|
|
350
274
|
* @param {string} camelCase - CamelCase string
|
|
@@ -459,40 +383,6 @@ const createDom = (fiber) => {
|
|
|
459
383
|
* @param {Object} nextProps - Next props
|
|
460
384
|
*/
|
|
461
385
|
const updateDom = (dom, prevProps = {}, nextProps = {}) => {
|
|
462
|
-
// Block dangerous properties
|
|
463
|
-
const dangerousProps = Object.keys(nextProps).filter(isDangerousProperty);
|
|
464
|
-
if (dangerousProps.length > 0) {
|
|
465
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
466
|
-
console.error(
|
|
467
|
-
`⚠️ SECURITY ERROR: Attempted to use ${DANGEROUS_PROPERTIES.join(', ')}: ${dangerousProps.join(', ')}. ` +
|
|
468
|
-
`These properties are blocked to prevent XSS injections. ` +
|
|
469
|
-
`If you need to insert HTML, use ${DANGEROUSLY_SET_INNER_HTML} with the structure: ` +
|
|
470
|
-
`{ ${DANGEROUSLY_SET_INNER_HTML}: { __html: 'your html here' } }`,
|
|
471
|
-
);
|
|
472
|
-
}
|
|
473
|
-
// Remove dangerous properties from nextProps to prevent their use
|
|
474
|
-
dangerousProps.forEach((prop) => {
|
|
475
|
-
delete nextProps[prop];
|
|
476
|
-
});
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
// Handle dangerouslySetInnerHTML
|
|
480
|
-
if (DANGEROUSLY_SET_INNER_HTML in nextProps) {
|
|
481
|
-
// If there are children along with dangerouslySetInnerHTML, warn
|
|
482
|
-
if (nextProps.children && nextProps.children.length > 0) {
|
|
483
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
484
|
-
console.warn(
|
|
485
|
-
`⚠️ WARNING: You cannot use children together with ${DANGEROUSLY_SET_INNER_HTML}. ` +
|
|
486
|
-
'Children will be ignored.',
|
|
487
|
-
);
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
applyDangerouslySetInnerHTML(dom, nextProps[DANGEROUSLY_SET_INNER_HTML]);
|
|
491
|
-
} else if (DANGEROUSLY_SET_INNER_HTML in prevProps) {
|
|
492
|
-
// If dangerouslySetInnerHTML was removed, clear innerHTML
|
|
493
|
-
dom.innerHTML = '';
|
|
494
|
-
}
|
|
495
|
-
|
|
496
386
|
// Remove old event listeners
|
|
497
387
|
Object.keys(prevProps)
|
|
498
388
|
.filter(isEvent)
|
|
@@ -520,20 +410,11 @@ const updateDom = (dom, prevProps = {}, nextProps = {}) => {
|
|
|
520
410
|
OLD_STRINGS.STYLE,
|
|
521
411
|
STRINGS.CLASS_NAME,
|
|
522
412
|
OLD_STRINGS.CLASS_NAME,
|
|
523
|
-
DANGEROUSLY_SET_INNER_HTML,
|
|
524
413
|
].includes(name)
|
|
525
414
|
) {
|
|
526
415
|
return
|
|
527
416
|
}
|
|
528
|
-
|
|
529
|
-
if (isDangerousProperty(name)) {
|
|
530
|
-
return
|
|
531
|
-
}
|
|
532
|
-
try {
|
|
533
|
-
dom[name] = '';
|
|
534
|
-
} catch (error) {
|
|
535
|
-
// Ignore errors when cleaning read-only properties
|
|
536
|
-
}
|
|
417
|
+
dom[name] = '';
|
|
537
418
|
});
|
|
538
419
|
|
|
539
420
|
// Set new properties
|
|
@@ -542,11 +423,6 @@ const updateDom = (dom, prevProps = {}, nextProps = {}) => {
|
|
|
542
423
|
.filter(isNew(prevProps, nextProps))
|
|
543
424
|
.forEach((name) => {
|
|
544
425
|
try {
|
|
545
|
-
// Skip dangerouslySetInnerHTML (already handled above)
|
|
546
|
-
if (name === DANGEROUSLY_SET_INNER_HTML) {
|
|
547
|
-
return
|
|
548
|
-
}
|
|
549
|
-
|
|
550
426
|
// Handle style properties
|
|
551
427
|
if (name === STRINGS.STYLE || name === OLD_STRINGS.STYLE) {
|
|
552
428
|
const styleValue = nextProps[name];
|