View Javadoc
1   /*
2    * Copyright (c) 2002-2025 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  @JsxClass(domClass = HtmlSpan.class)
33  public class HTMLSpanElement extends HTMLElement {
34  
35      private boolean endTagForbidden_;
36  
37      /**
38       * JavaScript constructor.
39       */
40      @Override
41      @JsxConstructor
42      public void jsConstructor() {
43          super.jsConstructor();
44      }
45  
46      /**
47       * Sets the DOM node that corresponds to this JavaScript object.
48       * @param domNode the DOM node
49       */
50      @Override
51      public void setDomNode(final DomNode domNode) {
52          super.setDomNode(domNode);
53          endTagForbidden_ = getBrowserVersion().hasFeature(HTMLBASEFONT_END_TAG_FORBIDDEN)
54                              && "basefont".equals(StringUtils.toRootLowerCase(domNode.getLocalName()));
55      }
56  
57      /**
58       * Returns the value of the {@code cite} property.
59       * @return the value of the {@code cite} property
60       */
61      public String getCite() {
62          return getDomNodeOrDie().getAttributeDirect("cite");
63      }
64  
65      /**
66       * Returns the value of the {@code cite} property.
67       * @param cite the value
68       */
69      public void setCite(final String cite) {
70          getDomNodeOrDie().setAttribute("cite", cite);
71      }
72  
73      /**
74       * Returns the value of the {@code dateTime} property.
75       * @return the value of the {@code dateTime} property
76       */
77      public String getDateTime() {
78          return getDomNodeOrDie().getAttributeDirect("datetime");
79      }
80  
81      /**
82       * Returns the value of the {@code dateTime} property.
83       * @param dateTime the value
84       */
85      public void setDateTime(final String dateTime) {
86          getDomNodeOrDie().setAttribute("datetime", dateTime);
87      }
88  
89      /**
90       * Returns whether the end tag is forbidden or not.
91       * @see <a href="http://www.w3.org/TR/html4/index/elements.html">HTML 4 specs</a>
92       * @return whether the end tag is forbidden or not
93       */
94      @Override
95      protected boolean isEndTagForbidden() {
96          return endTagForbidden_;
97      }
98  }