x4js 2.2.62 → 2.2.63
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/package.json
CHANGED
package/src/core/core_tools.ts
CHANGED
|
@@ -114,10 +114,29 @@ export function unsafeHtml(x: string): UnsafeHtml {
|
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
export function unsafe(strings: TemplateStringsArray, ...values: any[]): UnsafeHtml {
|
|
117
|
+
|
|
118
|
+
const resolve = ( value: any ) : string | UnsafeHtml => {
|
|
119
|
+
let v: string;
|
|
120
|
+
if( !value ) {
|
|
121
|
+
return "";
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if( isArray( value ) ) {
|
|
125
|
+
return value.map( resolve ).join( '' );
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if ( value instanceof UnsafeHtml ) {
|
|
129
|
+
return value.toString();
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return sanitizeHtml(value);
|
|
133
|
+
}
|
|
134
|
+
|
|
117
135
|
const result = strings.reduce((acc, str, i) => {
|
|
118
|
-
|
|
136
|
+
return acc + str + resolve( values[i] );
|
|
119
137
|
}, '');
|
|
120
|
-
|
|
138
|
+
|
|
139
|
+
return new UnsafeHtml(result);
|
|
121
140
|
}
|
|
122
141
|
|
|
123
142
|
/**
|