HEX
Server: Apache
System: Linux efa57bbe-abb1-400d-2985-3b056fbc2701.secureserver.net 6.1.147-1.el9.elrepo.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Jul 24 12:33:32 EDT 2025 x86_64
User: root (0)
PHP: 8.0.30.4
Disabled: NONE
Upload Files
File: /var/www/wp-content/plugins/pojo-accessibility/modules/remediation/assets/js/actions/element.js
import { Actions } from '../enum/actions';
import { RemediationBase } from './base';

export class ElementRemediation extends RemediationBase {
	run() {
		const { xpath, action, content, child } = this.data;
		const el = this.getElementByXPath(xpath);
		if (!el) {
			return false;
		}
		let childEl = null;
		if (child) {
			try {
				childEl = this.createElement(
					child.tag,
					child.attributes || [],
					child.content || '',
				);
			} catch (e) {
				return;
			}
		}
		switch (action) {
			case Actions.update:
				el.nodeValue = content;
				break;
			case Actions.remove:
				el.remove();
				break;
			case Actions.addChild:
				if (childEl) {
					el.appendChild(childEl);
				}
				break;
			case Actions.removeChild:
				if (childEl) {
					el.removeChild(childEl);
				}
				break;
			case Actions.addBefore:
				if (childEl && el.parentNode) {
					el.parentNode.insertBefore(childEl, el);
				}
				break;
			case Actions.addAfter:
				if (childEl && el.parentNode) {
					el.parentNode.insertBefore(childEl, el.nextSibling);
				}
				break;
		}

		return true;
	}
}