We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1290ba3 commit 226d190Copy full SHA for 226d190
src/instance/functions/style.js
@@ -215,3 +215,20 @@ export default function style(element) {
215
transition
216
}
217
218
+
219
+/**
220
+ * apply a CSS string to an element using the CSSOM (element.style) rather
221
+ * than setAttribute, which may violate the content security policy.
222
+ *
223
+ * @param {Node} [el] Element to receive styles.
224
+ * @param {string} [declaration] Styles to apply.
225
+ */
226
+export function applyStyle (el, declaration) {
227
+ declaration.split(';').forEach(pair => {
228
+ const [property, value] = pair.split(':').map(s => s.trim())
229
+ if (property && value) {
230
+ el.style[property] = value
231
+ }
232
+ })
233
+}
234
0 commit comments