1 /*
2 * Copyright (c) 2002-2026 Gargoyle Software Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 * https://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 package org.htmlunit.javascript.host.html;
16
17 import static org.htmlunit.BrowserVersionFeatures.HTMLBASEFONT_END_TAG_FORBIDDEN;
18
19 import org.htmlunit.html.DomNode;
20 import org.htmlunit.html.HtmlSpan;
21 import org.htmlunit.javascript.configuration.JsxClass;
22 import org.htmlunit.javascript.configuration.JsxConstructor;
23 import org.htmlunit.util.StringUtils;
24
25 /**
26 * The JavaScript object {@code HTMLSpanElement}.
27 *
28 * @author Ahmed Ashour
29 * @author Daniel Gredler
30 * @author Ronald Brill
31 *
32 * @see <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLSpanElement">MDN Documentation</a>
33 */
34 @JsxClass(domClass = HtmlSpan.class)
35 public class HTMLSpanElement extends HTMLElement {
36
37 private boolean endTagForbidden_;
38
39 /**
40 * JavaScript constructor.
41 */
42 @Override
43 @JsxConstructor
44 public void jsConstructor() {
45 super.jsConstructor();
46 }
47
48 /**
49 * Sets the DOM node that corresponds to this JavaScript object.
50 * @param domNode the DOM node
51 */
52 @Override
53 public void setDomNode(final DomNode domNode) {
54 super.setDomNode(domNode);
55 endTagForbidden_ = getBrowserVersion().hasFeature(HTMLBASEFONT_END_TAG_FORBIDDEN)
56 && "basefont".equals(StringUtils.toRootLowerCase(domNode.getLocalName()));
57 }
58
59 /**
60 * Returns the value of the {@code cite} property.
61 * @return the value of the {@code cite} property
62 */
63 public String getCite() {
64 return getDomNodeOrDie().getAttributeDirect("cite");
65 }
66
67 /**
68 * Sets the value of the {@code cite} property.
69 * @param cite the {@code cite} property value
70 */
71 public void setCite(final String cite) {
72 getDomNodeOrDie().setAttribute("cite", cite);
73 }
74
75 /**
76 * Returns the value of the {@code dateTime} property.
77 * @return the value of the {@code dateTime} property
78 */
79 public String getDateTime() {
80 return getDomNodeOrDie().getAttributeDirect("datetime");
81 }
82
83 /**
84 * Sets the value of the {@code dateTime} property.
85 * @param dateTime the {@code dateTime} property value
86 */
87 public void setDateTime(final String dateTime) {
88 getDomNodeOrDie().setAttribute("datetime", dateTime);
89 }
90
91 /**
92 * Returns whether the end tag is forbidden or not.
93 * @see <a href="http://www.w3.org/TR/html4/index/elements.html">HTML 4 specs</a>
94 * @return whether the end tag is forbidden or not
95 */
96 @Override
97 protected boolean isEndTagForbidden() {
98 return endTagForbidden_;
99 }
100 }