diff --git a/jso/apis/src/main/java/org/teavm/jso/dom/xml/CharacterData.java b/jso/apis/src/main/java/org/teavm/jso/dom/xml/CharacterData.java index 6382b7107b..b67f30bc89 100644 --- a/jso/apis/src/main/java/org/teavm/jso/dom/xml/CharacterData.java +++ b/jso/apis/src/main/java/org/teavm/jso/dom/xml/CharacterData.java @@ -16,8 +16,9 @@ package org.teavm.jso.dom.xml; import org.teavm.jso.JSProperty; +import org.teavm.jso.dom.xml.mixin.ChildNode; -public interface CharacterData extends Node { +public interface CharacterData extends Node, ChildNode { @JSProperty String getData(); diff --git a/jso/apis/src/main/java/org/teavm/jso/dom/xml/Document.java b/jso/apis/src/main/java/org/teavm/jso/dom/xml/Document.java index 88800f72fd..fc6745fecb 100644 --- a/jso/apis/src/main/java/org/teavm/jso/dom/xml/Document.java +++ b/jso/apis/src/main/java/org/teavm/jso/dom/xml/Document.java @@ -16,8 +16,9 @@ package org.teavm.jso.dom.xml; import org.teavm.jso.JSProperty; +import org.teavm.jso.dom.xml.mixin.ParentNode; -public interface Document extends Node { +public interface Document extends Node, ParentNode { @JSProperty DocumentType getDoctype(); @@ -54,8 +55,4 @@ public interface Document extends Node { NodeList getElementsByTagNameNS(String namespaceURI, String localName); Element getElementById(String elementId); - - Element querySelector(String selectors); - - NodeList querySelectorAll(String selectors); } diff --git a/jso/apis/src/main/java/org/teavm/jso/dom/xml/DocumentFragment.java b/jso/apis/src/main/java/org/teavm/jso/dom/xml/DocumentFragment.java index de581e7bd8..3319c70062 100644 --- a/jso/apis/src/main/java/org/teavm/jso/dom/xml/DocumentFragment.java +++ b/jso/apis/src/main/java/org/teavm/jso/dom/xml/DocumentFragment.java @@ -15,6 +15,8 @@ */ package org.teavm.jso.dom.xml; -public interface DocumentFragment extends Node { +import org.teavm.jso.dom.xml.mixin.ParentNode; + +public interface DocumentFragment extends Node, ParentNode { } diff --git a/jso/apis/src/main/java/org/teavm/jso/dom/xml/DocumentType.java b/jso/apis/src/main/java/org/teavm/jso/dom/xml/DocumentType.java index 66e251ce24..6882032ff4 100644 --- a/jso/apis/src/main/java/org/teavm/jso/dom/xml/DocumentType.java +++ b/jso/apis/src/main/java/org/teavm/jso/dom/xml/DocumentType.java @@ -16,8 +16,9 @@ package org.teavm.jso.dom.xml; import org.teavm.jso.JSProperty; +import org.teavm.jso.dom.xml.mixin.ChildNode; -public interface DocumentType extends Node { +public interface DocumentType extends Node, ChildNode { @JSProperty String getName(); diff --git a/jso/apis/src/main/java/org/teavm/jso/dom/xml/Element.java b/jso/apis/src/main/java/org/teavm/jso/dom/xml/Element.java index a718a495c1..520a6c85c3 100644 --- a/jso/apis/src/main/java/org/teavm/jso/dom/xml/Element.java +++ b/jso/apis/src/main/java/org/teavm/jso/dom/xml/Element.java @@ -16,8 +16,10 @@ package org.teavm.jso.dom.xml; import org.teavm.jso.JSProperty; +import org.teavm.jso.dom.xml.mixin.ChildNode; +import org.teavm.jso.dom.xml.mixin.ParentNode; -public interface Element extends Node { +public interface Element extends Node, ParentNode, ChildNode { String getAttribute(String name); void setAttribute(String name, String value); @@ -48,10 +50,14 @@ public interface Element extends Node { boolean hasAttributeNS(String namespaceURI, String localName); - Element querySelector(String selectors); + boolean toggleAttribute(String name); + + boolean toggleAttribute(String name, boolean force); + + Element closest(String selectors); + + boolean matches(String selectors); - NodeList querySelectorAll(String selectors); - @JSProperty String getId(); diff --git a/jso/apis/src/main/java/org/teavm/jso/dom/xml/Text.java b/jso/apis/src/main/java/org/teavm/jso/dom/xml/Text.java index 543cde9913..ef365a559b 100644 --- a/jso/apis/src/main/java/org/teavm/jso/dom/xml/Text.java +++ b/jso/apis/src/main/java/org/teavm/jso/dom/xml/Text.java @@ -15,6 +15,6 @@ */ package org.teavm.jso.dom.xml; -public interface Text extends Node { +public interface Text extends CharacterData { Text splitText(int offset); } diff --git a/jso/apis/src/main/java/org/teavm/jso/dom/xml/mixin/ChildNode.java b/jso/apis/src/main/java/org/teavm/jso/dom/xml/mixin/ChildNode.java new file mode 100644 index 0000000000..4ece0aac06 --- /dev/null +++ b/jso/apis/src/main/java/org/teavm/jso/dom/xml/mixin/ChildNode.java @@ -0,0 +1,26 @@ +/* + * Copyright 2025 Andi Rady Kurniawan. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.teavm.jso.dom.xml.mixin; + +public interface ChildNode { + void before(Object... nodes); + + void after(Object... nodes); + + void replaceWith(Object... nodes); + + void remove(); +} diff --git a/jso/apis/src/main/java/org/teavm/jso/dom/xml/mixin/ParentNode.java b/jso/apis/src/main/java/org/teavm/jso/dom/xml/mixin/ParentNode.java new file mode 100644 index 0000000000..06df5ffeb6 --- /dev/null +++ b/jso/apis/src/main/java/org/teavm/jso/dom/xml/mixin/ParentNode.java @@ -0,0 +1,31 @@ +/* + * Copyright 2025 Andi Rady Kurniawan. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.teavm.jso.dom.xml.mixin; + +import org.teavm.jso.dom.xml.Element; +import org.teavm.jso.dom.xml.NodeList; + +public interface ParentNode { + void prepend(Object... nodes); + + void append(Object... nodes); + + void replaceChildren(Object... nodes); + + Element querySelector(String selectors); + + NodeList querySelectorAll(String selectors); +}