Package dev.gmitch215.bytebox.html
Interface Element
- All Superinterfaces:
org.teavm.jso.JSObject
public interface Element
extends org.teavm.jso.JSObject
An element the rewriter has reached. Use it inside the handler call that received it.
Content is a string: text, escaped, or raw HTML with ContentOptions.html(). The
platform also takes a Response or a ReadableStream; those are not wrapped here.
- Since:
- 1.0.3
-
Method Summary
Modifier and TypeMethodDescriptionInserts text after the element.after(String content, ContentOptions options) Inserts content after the element.Inserts text right before the end tag.append(String content, ContentOptions options) Inserts content right before the end tag.Returns the attributes in document order, copied at the call.Inserts text before the element.before(String content, ContentOptions options) Inserts content before the element.getAttribute(String name) Reads an attribute.Returns the namespace URI, such ashttp://www.w3.org/1999/xhtml.Returns the tag name, such ash1.booleanhasAttribute(String name) Tests for an attribute.booleanReturns whether an earlier handler already removed or replaced this element.default voidonEndTag(EndTagHandler handler) Calls a handler when the element's end tag is reached.Inserts text right after the start tag.prepend(String content, ContentOptions options) Inserts content right after the start tag.remove()Removes the element with everything inside it.Removes the start and end tags and keeps what is inside.removeAttribute(String name) Removes an attribute.Replaces the element, with its content, by text.replace(String content, ContentOptions options) Replaces the element, with its content, by other content.setAttribute(String name, String value) Sets an attribute, adding it when the element has none.setInnerContent(String content) Replaces what is inside the element by text.setInnerContent(String content, ContentOptions options) Replaces what is inside the element by other content.voidsetTagName(String name) Renames the tag.Methods inherited from interface org.teavm.jso.JSObject
cast
-
Method Details
-
getTagName
String getTagName()Returns the tag name, such ash1.- Returns:
- the tag name, such as
h1
-
setTagName
Renames the tag.- Parameters:
name- the new name
-
isRemoved
boolean isRemoved()Returns whether an earlier handler already removed or replaced this element.- Returns:
- whether an earlier handler already removed or replaced this element
-
getNamespaceURI
String getNamespaceURI()Returns the namespace URI, such ashttp://www.w3.org/1999/xhtml.- Returns:
- the namespace URI, such as
http://www.w3.org/1999/xhtml
-
attributes
Returns the attributes in document order, copied at the call.- Returns:
- the attributes in document order, copied at the call
-
getAttribute
Reads an attribute.- Parameters:
name- the attribute name- Returns:
- the value, or
nullwhen the element has none
-
hasAttribute
Tests for an attribute.- Parameters:
name- the attribute name- Returns:
- whether the element has it
-
setAttribute
Sets an attribute, adding it when the element has none.- Parameters:
name- the attribute namevalue- the value- Returns:
- this element
-
removeAttribute
Removes an attribute.- Parameters:
name- the attribute name- Returns:
- this element
-
before
Inserts text before the element.- Parameters:
content- the text, escaped- Returns:
- this element
-
before
Inserts content before the element.- Parameters:
content- the contentoptions- how to read it- Returns:
- this element
-
after
Inserts text after the element.- Parameters:
content- the text, escaped- Returns:
- this element
-
after
Inserts content after the element.- Parameters:
content- the contentoptions- how to read it- Returns:
- this element
-
prepend
Inserts text right after the start tag.- Parameters:
content- the text, escaped- Returns:
- this element
-
prepend
Inserts content right after the start tag.- Parameters:
content- the contentoptions- how to read it- Returns:
- this element
-
append
Inserts text right before the end tag.- Parameters:
content- the text, escaped- Returns:
- this element
-
append
Inserts content right before the end tag.- Parameters:
content- the contentoptions- how to read it- Returns:
- this element
-
replace
Replaces the element, with its content, by text.- Parameters:
content- the text, escaped- Returns:
- this element
-
replace
Replaces the element, with its content, by other content.- Parameters:
content- the contentoptions- how to read it- Returns:
- this element
-
setInnerContent
Replaces what is inside the element by text.- Parameters:
content- the text, escaped- Returns:
- this element
-
setInnerContent
Replaces what is inside the element by other content.- Parameters:
content- the contentoptions- how to read it- Returns:
- this element
-
remove
Element remove()Removes the element with everything inside it.- Returns:
- this element
-
removeAndKeepContent
Element removeAndKeepContent()Removes the start and end tags and keeps what is inside.- Returns:
- this element
-
onEndTag
Calls a handler when the element's end tag is reached.- Parameters:
handler- the handler
-