commit 3f9560afb9622f316bef5a666ed16c3c472f8876
parent 6a2b1fff0f8f2861441cbcd3779fc5fa0e7ed6ce
Author: Henry Unite <unitehenry@gmail.com>
Date: Mon, 5 Oct 2020 08:52:07 -0400
prune inline styles unit test
Diffstat:
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/demo/src/test.js b/demo/src/test.js
@@ -93,7 +93,7 @@ describe('Regression Tests', () => {
}, 0);
}, 200);
});
-
+
it('should apply font format to content', done => {
const se = getEditor();
se.setContent('<p>Change me to an H1 format</p>');
@@ -241,6 +241,23 @@ describe('Unit Tests', () => {
assert.equal(denormalizeCamel('nocase'), 'Nocase');
assert.equal(denormalizeCamel('has_Underscore'), 'Has_ Underscore');
});
+
+ it("should change position to static", () => {
+ const se = getEditor();
+ const content = node(
+ `<div style="position: relative"></div>
+ <div style="position: fixed"></div>
+ <div style="position: sticky"></div>
+ <div style="position: absolute"></div>`
+ );
+
+ const pruned = se.pruneInlineStyles(content);
+
+ const prunedElementsWithStyle = pruned.querySelectorAll('*[style]');
+ const testArray = Array.from(prunedElementsWithStyle).filter(el=> el.style.position !== 'static')
+ assert.isEmpty(testArray, "inline styles are pruned");
+ se.clearContent();
+ });
});
mocha.run();
diff --git a/src/striveneditor.js b/src/striveneditor.js
@@ -2215,7 +2215,7 @@ export default class StrivenEditor {
/**
* Prunes inline position styles from elements
* @param {HTMLElement} el Element to prune inline styles from
- * @returns {HTMLElement} Reutrns the sanitized element
+ * @returns {HTMLElement} Returns the sanitized element
*/
pruneInlineStyles(el) {
let inlineStyleNodes = [...el.querySelectorAll('[style]')];