public final class TagName extends Object
StaticTagName or a PrintNode. We only
allow PrintNode for dynamic tag name at this point.
For {code @StaticTagName}, the equality semantics are based on the lower-ascii tag name and ignore source location. So 'DIV' and 'div' are considered equivalent.
For DynamicTagName, the equality semantics are based on the ExprRootNode
associated with the PrintNode.
| Modifier and Type | Class and Description |
|---|---|
static class |
TagName.RcDataTagName
An enum to represent tags that have
rcdata content. |
| Constructor and Description |
|---|
TagName(PrintNode node) |
TagName(RawTextNode node) |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
checkOptionalTagShouldBePopped(TagName openTag,
TagName closeTag)
Checks if the an open tag can be auto-closed by a following close tag.
|
boolean |
equals(Object other) |
PrintNode |
getDynamicTagName() |
SoyNode.StandaloneNode |
getNode() |
TagName.RcDataTagName |
getRcDataTagName()
Returns the
TagName.RcDataTagName for this node, if any. |
String |
getStaticTagName()
Returns the static name.
|
String |
getStaticTagNameAsLowerCase()
Returns the static name in ascii lowercase.
|
SourceLocation |
getTagLocation() |
int |
hashCode() |
boolean |
isDefinitelyOptional() |
boolean |
isDefinitelyVoid() |
boolean |
isForeignContent() |
boolean |
isStatic() |
String |
toString() |
public TagName(RawTextNode node)
public TagName(PrintNode node)
public boolean isStatic()
public boolean isDefinitelyVoid()
public boolean isDefinitelyOptional()
public static boolean checkOptionalTagShouldBePopped(TagName openTag, TagName closeTag)
We throws an IllegalArgumentException if two inputs have the same tag names, since
this should never happen (should be handled by previous logic in StrictHtmlValidationPass).
This implements half of the content model described in
https://www.w3.org/TR/html5/syntax.html#optional-tags. Notably we do nothing when we see cases
like "li element is immediately followed by another li element". The validation logic relies on
auto-closing open tags when we see close tags. Since only </ul> and </ol> are
allowed to pop <li>, we believe this should still give us a confident error message. We
might consider adding support for popping open tags when we visit open tags in the future.
public boolean isForeignContent()
@Nullable public TagName.RcDataTagName getRcDataTagName()
TagName.RcDataTagName for this node, if any.public String getStaticTagName()
public String getStaticTagNameAsLowerCase()
IllegalStateException - if this tag name isn't static.public SoyNode.StandaloneNode getNode()
public PrintNode getDynamicTagName()
public SourceLocation getTagLocation()