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 826369c commit 0612d03Copy full SHA for 0612d03
src/js/_enqueues/wp/sanitize.js
@@ -25,12 +25,12 @@
25
stripTags: function( text ) {
26
let _text = text || '';
27
28
- const htmlElement = document.createElement( 'div' );
29
- htmlElement.innerHTML = _text;
30
- _text = htmlElement.textContent || htmlElement.innerText || '';
+ const domParser = new DOMParser();
+ const htmlDocument = domParser.parseFromString( _text, 'text/html' );
+ htmlDocument.body.innerText = htmlDocument.body.innerText || '';
31
32
// Return the text with stripped tags.
33
- return _text;
+ return htmlDocument.body.innerHTML;
34
},
35
36
/**
0 commit comments