Add coexistence checks to all enqueue methods to prevent loading both React and Grid.js assets simultaneously. Changes: - ReactAdmin.php: Only enqueue React assets when ?react=1 - Init.php: Skip Grid.js when React active on admin pages - Form.php, Coupon.php, Access.php: Restore classic assets when ?react=0 - Customer.php, Product.php, License.php: Add coexistence checks Now the toggle between Classic and React versions works correctly. Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
38 lines
923 B
JavaScript
38 lines
923 B
JavaScript
/**
|
|
* Internal dependencies
|
|
*/
|
|
import remove from './remove';
|
|
|
|
/**
|
|
* Strips scripts and on* attributes from HTML.
|
|
*
|
|
* @param {string} html HTML to sanitize.
|
|
*
|
|
* @return {string} The sanitized HTML.
|
|
*/
|
|
export default function safeHTML(html) {
|
|
const {
|
|
body
|
|
} = document.implementation.createHTMLDocument('');
|
|
body.innerHTML = html;
|
|
const elements = body.getElementsByTagName('*');
|
|
let elementIndex = elements.length;
|
|
while (elementIndex--) {
|
|
const element = elements[elementIndex];
|
|
if (element.tagName === 'SCRIPT') {
|
|
remove(element);
|
|
} else {
|
|
let attributeIndex = element.attributes.length;
|
|
while (attributeIndex--) {
|
|
const {
|
|
name: key
|
|
} = element.attributes[attributeIndex];
|
|
if (key.startsWith('on')) {
|
|
element.removeAttribute(key);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return body.innerHTML;
|
|
}
|
|
//# sourceMappingURL=safe-html.js.map
|