rasti 4.0.0-alpha.11 → 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 +28 -15
- package/dist/rasti.js.map +1 -1
- package/dist/rasti.min.js +1 -1
- package/dist/rasti.min.js.map +1 -1
- package/es/View.js +28 -15
- package/es/View.js.map +1 -1
- package/lib/View.cjs +28 -15
- package/lib/View.cjs.map +1 -1
- package/package.json +2 -3
- package/src/View.js +28 -15
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
|
@@ -794,7 +794,14 @@
|
|
|
794
794
|
* }
|
|
795
795
|
*
|
|
796
796
|
* template(model) {
|
|
797
|
-
* 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;
|
|
798
805
|
* }
|
|
799
806
|
* }
|
|
800
807
|
* // Render view and append view's element into the body.
|
|
@@ -1088,23 +1095,29 @@
|
|
|
1088
1095
|
}
|
|
1089
1096
|
|
|
1090
1097
|
/**
|
|
1091
|
-
*
|
|
1092
|
-
*
|
|
1093
|
-
*
|
|
1094
|
-
*
|
|
1095
|
-
* If you add any child views, you should call `this.destroyChildren` before re-rendering.
|
|
1096
|
-
* The default implementation updates `this.el`'s innerHTML with the result
|
|
1097
|
-
* of calling `this.template`, passing `this.model` as the argument.
|
|
1098
|
-
* <br><br> ⚠ **Security Notice:** The default implementation utilizes `innerHTML`, which may introduce Cross-Site Scripting (XSS) risks.
|
|
1099
|
-
* Ensure that any user-generated content is properly sanitized before inserting it into the DOM.
|
|
1100
|
-
* You can use the {@link #module_view_sanitize View.sanitize} static method to escape HTML entities in a string.
|
|
1101
|
-
* For best practices on secure data handling, refer to the
|
|
1102
|
-
* [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
|
+
*
|
|
1103
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
|
+
* }
|
|
1104
1119
|
*/
|
|
1105
1120
|
render() {
|
|
1106
|
-
if (this.template) this.el.innerHTML = this.template(this.model);
|
|
1107
|
-
// Return `this` for chaining.
|
|
1108
1121
|
return this;
|
|
1109
1122
|
}
|
|
1110
1123
|
|