@webtides/element-js 1.2.0 → 1.2.1
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
|
@@ -6,7 +6,7 @@ const voidElements = /^(?:area|base|br|col|embed|hr|img|input|link|meta|source|t
|
|
|
6
6
|
const rawTextElements = /<(script|style|textarea|title)([^>]*)>(.*?)<\/\1>/i;
|
|
7
7
|
const elements = /<([a-z]+[a-z0-9:._-]*)([^>]*?)(\/?)>/g;
|
|
8
8
|
// TODO: v this will not match any values with escaped quotes like onClick='console.log("\'test")'
|
|
9
|
-
const attributes = /([^\s]*)=((?:")[^"]*(?:")|(?:')[^']*(?:')|[^\s\/>]*)|([^\s\/>]*)/g;
|
|
9
|
+
const attributes = /([^\s=]*)=((?:")[^"]*(?:")|(?:')[^']*(?:')|[^\s\/>]*)|([^\s\/>]*)/g;
|
|
10
10
|
const partPositions = /[\x01\x02]/g;
|
|
11
11
|
const ssrPlaceholder = /{{dom-part\?(.*?)}}/g;
|
|
12
12
|
// \x01 Node.ELEMENT_NODE
|
|
@@ -125,16 +125,20 @@ export function camelToDash(string) {
|
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
/**
|
|
128
|
-
* Decodes an attribute according to {@link https://html.spec.whatwg.org/multipage/syntax.html#attributes-2}
|
|
128
|
+
* Decodes an attribute according to {@link https://html.spec.whatwg.org/multipage/syntax.html#attributes-2} & {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}
|
|
129
129
|
* @param {string} attribute
|
|
130
130
|
* @returns {string}
|
|
131
131
|
*/
|
|
132
132
|
export function decodeAttribute(attribute) {
|
|
133
|
-
return `${attribute}
|
|
133
|
+
return `${attribute}`
|
|
134
|
+
.replace(/</g, '<')
|
|
135
|
+
.replace(/>/g, '>')
|
|
136
|
+
.replace(/"/g, '"')
|
|
137
|
+
.replace(/&/g, '&');
|
|
134
138
|
}
|
|
135
139
|
|
|
136
140
|
/**
|
|
137
|
-
* Encodes an attribute according to {@link https://html.spec.whatwg.org/multipage/syntax.html#attributes-2}
|
|
141
|
+
* Encodes an attribute according to {@link https://html.spec.whatwg.org/multipage/syntax.html#attributes-2} & {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}
|
|
138
142
|
* @param {string} attribute
|
|
139
143
|
* @returns {string}
|
|
140
144
|
*/
|
|
@@ -142,6 +146,8 @@ export function encodeAttribute(attribute) {
|
|
|
142
146
|
return `${attribute}`
|
|
143
147
|
.replace(/&/g, '&')
|
|
144
148
|
.replace(/"/g, '"')
|
|
149
|
+
.replace(/</g, '<')
|
|
150
|
+
.replace(/>/g, '>')
|
|
145
151
|
.replace(/\r\n/g, '\n')
|
|
146
152
|
.replace(/[\r\n]/g, '\n');
|
|
147
153
|
}
|