Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added some missing dom methods and properties #313

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions jso/apis/src/main/java/org/teavm/jso/dom/events/MouseEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,24 @@ public interface MouseEvent extends Event {
@JSProperty
int getClientY();

@JSProperty
int getPageX();

@JSProperty
int getPageY();

@JSProperty
int getOffsetX();

@JSProperty
int getOffsetY();

@JSProperty
int getX();

@JSProperty
int getY();

@JSProperty
boolean getCtrlKey();

Expand Down
15 changes: 15 additions & 0 deletions jso/apis/src/main/java/org/teavm/jso/dom/html/HTMLElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,21 @@ public interface HTMLElement extends Element, ElementCSSInlineStyle, EventTarget
@JSProperty
void setClassName(String className);

@JSProperty
HTMLElement getOffsetParent();

@JSProperty
int getOffsetTop();

@JSProperty
int getOffsetLeft();

@JSProperty
int getOffsetWidth();

@JSProperty
int getOffsetHeight();

default HTMLElement withAttr(String name, String value) {
setAttribute(name, value);
return this;
Expand Down
31 changes: 31 additions & 0 deletions jso/apis/src/main/java/org/teavm/jso/dom/xml/DOMTokenList.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright 2017 Colin Alworth.
*
* 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;

import org.teavm.jso.core.JSArrayReader;
import org.teavm.jso.core.JSString;

public interface DOMTokenList extends JSArrayReader<JSString> {
boolean contains(String token);

void add(String... tokens);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if varargs are supported in JSO. Please check. If they aren't, let's think how we can work-around this. And don't forget to create an issue to support vararg.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A good question - I'll verify more thoroughly, but I can verify that calling add(String...) with a single argument does work as expected presently.


void remove(String... tokens);

boolean toggle(String token);

boolean toggle(String token, boolean force);
}
9 changes: 9 additions & 0 deletions jso/apis/src/main/java/org/teavm/jso/dom/xml/Element.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package org.teavm.jso.dom.xml;

import org.teavm.jso.JSProperty;

public interface Element extends Node {
String getTagName();

Expand Down Expand Up @@ -47,4 +49,11 @@ public interface Element extends Node {
boolean hasAttribute(String name);

boolean hasAttributeNS(String namespaceURI, String localName);

Element querySelector(String selectors);

NodeList<Element> querySelectorAll(String selectors);

@JSProperty
DOMTokenList getClassList();
}