From 736d2b8e2bb7f95083c400b064a9fa2d369b2a19 Mon Sep 17 00:00:00 2001 From: Ronald Brill Date: Fri, 22 Nov 2024 20:30:43 +0100 Subject: [PATCH] fix attrib index handling --- src/main/java/org/htmlunit/html/DomAttr.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/org/htmlunit/html/DomAttr.java b/src/main/java/org/htmlunit/html/DomAttr.java index e9e8cc6092..b4a3d6c78f 100644 --- a/src/main/java/org/htmlunit/html/DomAttr.java +++ b/src/main/java/org/htmlunit/html/DomAttr.java @@ -174,6 +174,15 @@ public String getTextContent() { */ @Override public void setTextContent(final String textContent) { + final boolean mappedElement = + getOwnerDocument() instanceof HtmlPage + && (DomElement.NAME_ATTRIBUTE.equals(getName()) || DomElement.ID_ATTRIBUTE.equals(getName())); + if (mappedElement) { + ((HtmlPage) getPage()).removeMappedElement(getOwnerElement(), false, false); + } setValue(textContent); + if (mappedElement) { + ((HtmlPage) getPage()).addMappedElement(getOwnerElement(), false); + } } }