rasti 4.0.0-alpha.10 → 4.0.0-alpha.12
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/README.md +2 -2
- package/dist/rasti.js +32 -16
- package/dist/rasti.js.map +1 -1
- package/dist/rasti.min.js +1 -1
- package/dist/rasti.min.js.map +1 -1
- package/es/Component.js +3 -1
- package/es/Component.js.map +1 -1
- package/es/View.js +28 -15
- package/es/View.js.map +1 -1
- package/es/utils/dev.js +1 -0
- package/es/utils/dev.js.map +1 -1
- package/lib/Component.cjs +3 -1
- package/lib/Component.cjs.map +1 -1
- package/lib/View.cjs +28 -15
- package/lib/View.cjs.map +1 -1
- package/lib/utils/dev.cjs +1 -0
- package/lib/utils/dev.cjs.map +1 -1
- package/package.json +2 -3
- package/src/Component.js +3 -1
- package/src/View.js +28 -15
- package/src/utils/dev.js +1 -0
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<p align="center">
|
|
2
2
|
<picture>
|
|
3
|
-
<source media="(prefers-color-scheme: dark)" srcset="https://cdn.jsdelivr.net/gh/8tentaculos/rasti@v4.0.0-alpha.
|
|
4
|
-
<img alt="Rasti.js" src="https://cdn.jsdelivr.net/gh/8tentaculos/rasti@v4.0.0-alpha.
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://cdn.jsdelivr.net/gh/8tentaculos/rasti@v4.0.0-alpha.12/docs/logo-dark.svg">
|
|
4
|
+
<img alt="Rasti.js" src="https://cdn.jsdelivr.net/gh/8tentaculos/rasti@v4.0.0-alpha.12/docs/logo.svg" height="120">
|
|
5
5
|
</picture>
|
|
6
6
|
</p>
|
|
7
7
|
|
package/dist/rasti.js
CHANGED
|
@@ -78,6 +78,7 @@
|
|
|
78
78
|
* - UMD dev: replaced with true
|
|
79
79
|
* - UMD prod: replaced with false
|
|
80
80
|
* @type {boolean}
|
|
81
|
+
* @module
|
|
81
82
|
* @private
|
|
82
83
|
*/
|
|
83
84
|
const __DEV__ = true;
|
|
@@ -793,7 +794,14 @@
|
|
|
793
794
|
* }
|
|
794
795
|
*
|
|
795
796
|
* template(model) {
|
|
796
|
-
* return `Seconds: <span>${model.seconds}</span>`;
|
|
797
|
+
* return `Seconds: <span>${View.sanitize(model.seconds)}</span>`;
|
|
798
|
+
* }
|
|
799
|
+
*
|
|
800
|
+
* render() {
|
|
801
|
+
* if (this.template) {
|
|
802
|
+
* this.el.innerHTML = this.template(this.model);
|
|
803
|
+
* }
|
|
804
|
+
* return this;
|
|
797
805
|
* }
|
|
798
806
|
* }
|
|
799
807
|
* // Render view and append view's element into the body.
|
|
@@ -1087,23 +1095,29 @@
|
|
|
1087
1095
|
}
|
|
1088
1096
|
|
|
1089
1097
|
/**
|
|
1090
|
-
*
|
|
1091
|
-
*
|
|
1092
|
-
*
|
|
1093
|
-
*
|
|
1094
|
-
* If you add any child views, you should call `this.destroyChildren` before re-rendering.
|
|
1095
|
-
* The default implementation updates `this.el`'s innerHTML with the result
|
|
1096
|
-
* of calling `this.template`, passing `this.model` as the argument.
|
|
1097
|
-
* <br><br> ⚠ **Security Notice:** The default implementation utilizes `innerHTML`, which may introduce Cross-Site Scripting (XSS) risks.
|
|
1098
|
-
* Ensure that any user-generated content is properly sanitized before inserting it into the DOM.
|
|
1099
|
-
* You can use the {@link #module_view_sanitize View.sanitize} static method to escape HTML entities in a string.
|
|
1100
|
-
* For best practices on secure data handling, refer to the
|
|
1101
|
-
* [OWASP's XSS Prevention Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Cross_Site_Scripting_Prevention_Cheat_Sheet.html).<br><br>
|
|
1098
|
+
* `render` is the core function that your view should override, in order to populate its element (`this.el`), with the appropriate HTML. The convention is for `render` to always return `this`.
|
|
1099
|
+
* Views are low-level building blocks for creating user interfaces. For most use cases, we recommend using {@link #module_component Component} instead, which provides a more declarative template syntax, automatic DOM updates, and a more efficient render pipeline.
|
|
1100
|
+
* If you add any child views, you should call `this.destroyChildren` before re-rendering.
|
|
1101
|
+
*
|
|
1102
1102
|
* @return {View} Returns `this` for chaining.
|
|
1103
|
+
* @example
|
|
1104
|
+
* class UserView extends View {
|
|
1105
|
+
* render() {
|
|
1106
|
+
* if (this.template) {
|
|
1107
|
+
* const model = this.model;
|
|
1108
|
+
* // Sanitize model attributes to prevent XSS attacks.
|
|
1109
|
+
* const safeData = {
|
|
1110
|
+
* name : View.sanitize(model.name),
|
|
1111
|
+
* email : View.sanitize(model.email),
|
|
1112
|
+
* bio : View.sanitize(model.bio)
|
|
1113
|
+
* };
|
|
1114
|
+
* this.el.innerHTML = this.template(safeData);
|
|
1115
|
+
* }
|
|
1116
|
+
* return this;
|
|
1117
|
+
* }
|
|
1118
|
+
* }
|
|
1103
1119
|
*/
|
|
1104
1120
|
render() {
|
|
1105
|
-
if (this.template) this.el.innerHTML = this.template(this.model);
|
|
1106
|
-
// Return `this` for chaining.
|
|
1107
1121
|
return this;
|
|
1108
1122
|
}
|
|
1109
1123
|
|
|
@@ -1936,7 +1950,9 @@
|
|
|
1936
1950
|
* @return {boolean} True if the element contains a component.
|
|
1937
1951
|
* @private
|
|
1938
1952
|
*/
|
|
1939
|
-
const containsElement = (el) => !!(
|
|
1953
|
+
const containsElement = (el) => !!(
|
|
1954
|
+
el && ((el.dataset && el.dataset[Component.DATASET_ELEMENT]) || (el.querySelector && el.querySelector(`[${Component.ATTRIBUTE_ELEMENT}]`)))
|
|
1955
|
+
);
|
|
1940
1956
|
|
|
1941
1957
|
/**
|
|
1942
1958
|
* Generate string with placeholders for interpolated expressions.
|