rasti 4.1.0 → 4.1.1-alpha.0
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 +20 -1
- package/dist/rasti.js.map +1 -1
- package/dist/rasti.min.js +1 -1
- package/dist/rasti.min.js.map +1 -1
- package/es/utils/getAttributesHTML.js +20 -1
- package/es/utils/getAttributesHTML.js.map +1 -1
- package/lib/utils/getAttributesHTML.cjs +20 -1
- package/lib/utils/getAttributesHTML.cjs.map +1 -1
- package/package.json +1 -1
- package/src/utils/getAttributesHTML.js +20 -1
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.1.0/docs/logo-dark.svg">
|
|
4
|
-
<img alt="Rasti.js" src="https://cdn.jsdelivr.net/gh/8tentaculos/rasti@v4.1.0/docs/logo.svg" height="120">
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://cdn.jsdelivr.net/gh/8tentaculos/rasti@v4.1.1-alpha.0/docs/logo-dark.svg">
|
|
4
|
+
<img alt="Rasti.js" src="https://cdn.jsdelivr.net/gh/8tentaculos/rasti@v4.1.1-alpha.0/docs/logo.svg" height="120">
|
|
5
5
|
</picture>
|
|
6
6
|
</p>
|
|
7
7
|
|
package/dist/rasti.js
CHANGED
|
@@ -1710,6 +1710,23 @@
|
|
|
1710
1710
|
return fragment.content;
|
|
1711
1711
|
}
|
|
1712
1712
|
|
|
1713
|
+
/**
|
|
1714
|
+
* Characters that terminate an attribute name. A name containing any of them
|
|
1715
|
+
* would let the rest of the value be parsed as markup instead of as a name.
|
|
1716
|
+
* @type {RegExp}
|
|
1717
|
+
* @private
|
|
1718
|
+
*/
|
|
1719
|
+
const INVALID_ATTRIBUTE_NAME = /[\s"'>/=]/;
|
|
1720
|
+
|
|
1721
|
+
/**
|
|
1722
|
+
* Escape an attribute value. Values are serialized inside double quotes,
|
|
1723
|
+
* so escaping the double quote keeps the value from terminating the attribute.
|
|
1724
|
+
* @param {string} value Attribute value.
|
|
1725
|
+
* @return {string} Escaped attribute value.
|
|
1726
|
+
* @private
|
|
1727
|
+
*/
|
|
1728
|
+
const escapeAttributeValue = value => `${value}`.replace(/"/g, '"');
|
|
1729
|
+
|
|
1713
1730
|
/**
|
|
1714
1731
|
* Generate HTML string from attributes object.
|
|
1715
1732
|
* @param {Object} attributes Object containing attribute names and values.
|
|
@@ -1722,12 +1739,14 @@
|
|
|
1722
1739
|
|
|
1723
1740
|
Object.keys(attributes).forEach(key => {
|
|
1724
1741
|
let value = attributes[key];
|
|
1742
|
+
// Skip invalid names, they can't be serialized as an attribute.
|
|
1743
|
+
if (INVALID_ATTRIBUTE_NAME.test(key)) return;
|
|
1725
1744
|
|
|
1726
1745
|
if (value === true) {
|
|
1727
1746
|
html.push(key);
|
|
1728
1747
|
} else if (value !== false) {
|
|
1729
1748
|
if (value === null || typeof value === 'undefined') value = '';
|
|
1730
|
-
html.push(`${key}="${value}"`);
|
|
1749
|
+
html.push(`${key}="${escapeAttributeValue(value)}"`);
|
|
1731
1750
|
}
|
|
1732
1751
|
});
|
|
1733
1752
|
|