Package org.htmlunit.html
Class ScriptElementSupport
java.lang.Object
org.htmlunit.html.ScriptElementSupport
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
A helper class to be used by elements which support
A helper class to be used by elements which support
ScriptElement
.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final org.apache.commons.logging.Log
private static final String
Invalid source attribute which should be ignored (used by JS libraries like jQuery). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static void
executeEvent
(DomElement element, String type) private static void
executeInlineScriptIfNeeded
(DomElement element) Executes this script node as inline script if necessary and/or possible.static void
executeScriptIfNeeded
(DomElement element, boolean ignoreAttachedToPage, boolean ignorePageIsAncestor) INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Executes this script node if necessary and/or possible.private static String
getScriptCode
(DomElement element) Gets the script held within the script tag.private static boolean
isExecutionNeeded
(DomElement element, boolean ignoreAttachedToPage, boolean ignorePageIsAncestor) Indicates if script execution is necessary and/or possible.static boolean
isJavaScript
(DomElement element, String typeAttribute, String languageAttribute) Returns true if a script with the specified type and language attributes is actually JavaScript.static void
onAllChildrenAddedToPage
(DomElement element, boolean postponed) Lifecycle method invoked after a node and all its children have been added to a page, during parsing of the HTML.
-
Field Details
-
LOG
private static final org.apache.commons.logging.Log LOG -
SLASH_SLASH_COLON
Invalid source attribute which should be ignored (used by JS libraries like jQuery).- See Also:
-
-
Constructor Details
-
ScriptElementSupport
private ScriptElementSupport()
-
-
Method Details
-
onAllChildrenAddedToPage
Lifecycle method invoked after a node and all its children have been added to a page, during parsing of the HTML. Intended to be overridden by nodes which need to perform custom logic after they and all their child nodes have been processed by the HTML parser. This method is not recursive, and the default implementation is empty, so there is no need to callsuper.onAllChildrenAddedToPage()
if you implement this method.- Parameters:
element
- the elementpostponed
- whether to usePostponedAction
or no
-
executeScriptIfNeeded
public static void executeScriptIfNeeded(DomElement element, boolean ignoreAttachedToPage, boolean ignorePageIsAncestor) INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Executes this script node if necessary and/or possible.- Parameters:
element
- the elementignoreAttachedToPage
- don't do the isAttachedToPage checkignorePageIsAncestor
- don't do the element.getPage().isAncestorOf(element) check
-
isExecutionNeeded
private static boolean isExecutionNeeded(DomElement element, boolean ignoreAttachedToPage, boolean ignorePageIsAncestor) Indicates if script execution is necessary and/or possible.- Parameters:
element
- the elementignoreAttachedToPage
- don't do the isAttachedToPage checkignorePageIsAncestor
- don't do the element.getPage().isAncestorOf(element) check- Returns:
true
if the script should be executed
-
isJavaScript
public static boolean isJavaScript(DomElement element, String typeAttribute, String languageAttribute) Returns true if a script with the specified type and language attributes is actually JavaScript. According to W3C recommendation are content types case insensitive.- Parameters:
element
- the elementtypeAttribute
- the type attribute specified in the script taglanguageAttribute
- the language attribute specified in the script tag- Returns:
- true if the script is JavaScript
-
executeEvent
-
executeInlineScriptIfNeeded
Executes this script node as inline script if necessary and/or possible. -
getScriptCode
Gets the script held within the script tag.
-