Class Index | File Index

Classes


Class myfaces._impl._util._Dom


Extends myfaces._impl.core._Runtime.

Defined in: _Dom.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Object singleton collection of dom helper routines (which in later incarnations will get browser specific speed optimizations) Since we have to be as tight as possible we will focus with our dom routines to only the parts which our impl uses.
Method Summary
Method Attributes Method Name and Description
 
byIdOrName(elem)
determines to fetch a node from its id or name, the name case only works if the element is unique in its name
 
concatenation routine which concats all childnodes of a node which contains a set of CDATA blocks to one big string
 
standard constructor
 
createElement(nodeName, attrs)
creates a node upon a given node name
 
deleteItem(itemIdToReplace)
Simple delete on an existing item
 
detach(items)
detaches a set of nodes from their parent elements in a browser independend manner
 
findAll(rootNode, filter, deepScan)
a filtered findAll for subdom treewalking (which uses browser optimizations wherever possible)
 
findByTagName(fragment, tagName)
determines the number of nodes according to their tagType
 
findByTagNames(fragment, tagNames)
optimized search for an array of tag names deep scan will always be performed.
 
fuzzy form detection which tries to determine the form an item has been detached.
 
getAttribute(node, attr)
cross ported from dojo fetches an attribute from a node
 
getFilteredParent(item, filter)
A parent walker which uses a filter closure for filtering
 
getParent(item, tagName)
gets a parent of an item with a given tagname
 
fetches the window id for the current request note, this is a preparation method for jsf 2.2
 
hasAttribute(node, attr)
checks whether the given node has an attribute attached
 
insertAfter(item, markup)
proper insert before which takes tables into consideration as well as browser deficiencies
 
insertBefore(item, markup)
proper insert before which takes tables into consideration as well as browser deficiencies
 
Checks whether the browser is dom compliant.
 
node id or name, determines the valid form identifier of a node depending on its uniqueness Usually the id is chosen for an elem, but if the id does not exist we try a name fallback.
 
outerHTML(item, markup, preserveFocus,)
outerHTML replacement which works cross browserlike but still is speed optimized
 
replaceElement(item, evalNode)
for performance reasons we work with replaceElement and replaceElements here after measuring performance it has shown that passing down an array instead of a single node makes replaceElement twice as slow, however a single node case is the 95% case
 
replaceElements(item, evalNodes)
replaces an element with another element or a set of elements
 
runScripts(item, xmlData)
Run through the given Html item and execute the inline scripts (IE doesn't do this by itself)
 
setAttribute(node, attr, val)
bugfixing for ie6 which does not cope properly with setAttribute
Class Detail
myfaces._impl._util._Dom()
Object singleton collection of dom helper routines (which in later incarnations will get browser specific speed optimizations) Since we have to be as tight as possible we will focus with our dom routines to only the parts which our impl uses. A jquery like query API would be nice but this would increase up our codebase significantly

This class provides the proper fallbacks for ie8- and Firefox 3.6-

Method Detail
byIdOrName(elem)
determines to fetch a node from its id or name, the name case only works if the element is unique in its name
Parameters:
{String} elem

concatCDATABlocks(node)
concatenation routine which concats all childnodes of a node which contains a set of CDATA blocks to one big string
Parameters:
{Node} node
the node to concat its blocks for

constructor_()
standard constructor

createElement(nodeName, attrs)
creates a node upon a given node name
Parameters:
nodeName
{String} the node name to be created
attrs
{Array} a set of attributes to be set

deleteItem(itemIdToReplace)
Simple delete on an existing item
Parameters:
itemIdToReplace

{Array} detach(items)
detaches a set of nodes from their parent elements in a browser independend manner
Parameters:
{Object} items
the items which need to be detached
Returns:
{Array} an array of nodes with the detached dom nodes

findAll(rootNode, filter, deepScan)
a filtered findAll for subdom treewalking (which uses browser optimizations wherever possible)
Parameters:
{|Node|} rootNode
the rootNode so start the scan
filter
filter closure with the syntax {boolean} filter({Node} node)
deepScan
if set to true or not set at all a deep scan is performed (for form scans it does not make much sense to deeply scan)

findByTagName(fragment, tagName)
determines the number of nodes according to their tagType
Parameters:
{Node} fragment
(Node or fragment) the fragment to be investigated
{String} tagName
the tag name (lowercase) (the normal usecase is false, which means if the element is found only its adjacent elements will be scanned, due to the recursive descension this should work out with elements with different nesting depths but not being parent and child to each other
Returns:
the child elements as array or null if nothing is found

findByTagNames(fragment, tagNames)
optimized search for an array of tag names deep scan will always be performed.
Parameters:
fragment
the fragment which should be searched for
tagNames
an map indx of tag names which have to be found

fuzzyFormDetection(elem)
fuzzy form detection which tries to determine the form an item has been detached. The problem is some Javascript libraries simply try to detach controls by reusing the names of the detached input controls. Most of the times, the name is unique in a jsf scenario, due to the inherent form mapping. One way or the other, we will try to fix that by identifying the proper form over the name We do it in several ways, in case of no form null is returned in case of multiple forms we check all elements with a given name (which we determine out of a name or id of the detached element) and then iterate over them to find whether they are in a form or not. If only one element within a form and a given identifier found then we can pull out and move on We cannot do much further because in case of two identical named elements all checks must fail and the first elements form is served. Note, this method is only triggered in case of the issuer or an ajax request is a detached element, otherwise already existing code has served the correct form. This method was added because of https://issues.apache.org/jira/browse/MYFACES-2599 to support the integration of existing ajax libraries which do heavy dom manipulation on the controls side (Dojos Dijit library for instance).
Parameters:
{Node} elem
- element as source, can be detached, undefined or null
Returns:
either null or a form node if it could be determined TODO move this into extended and replace it with a simpler algorithm

getAttribute(node, attr)
cross ported from dojo fetches an attribute from a node
Parameters:
{String} node
the node
{String} attr
the attribute
Returns:
the attributes value or null

getFilteredParent(item, filter)
A parent walker which uses a filter closure for filtering
Parameters:
{Node} item
the root item to ascend from
{function} filter
the filter closure

getParent(item, tagName)
gets a parent of an item with a given tagname
Parameters:
{Node} item
- child element
{String} tagName
- TagName of parent element

getWindowId()
fetches the window id for the current request note, this is a preparation method for jsf 2.2

hasAttribute(node, attr)
checks whether the given node has an attribute attached
Parameters:
{String|Object} node
the node to search for
{String} attr
the attribute to search for

insertAfter(item, markup)
proper insert before which takes tables into consideration as well as browser deficiencies
Parameters:
item
the node to insert before
markup
the markup to be inserted

insertBefore(item, markup)
proper insert before which takes tables into consideration as well as browser deficiencies
Parameters:
item
the node to insert before
markup
the markup to be inserted

isDomCompliant()
Checks whether the browser is dom compliant. Dom compliant means that it performs the basic dom operations safely without leaking and also is able to perform a native setAttribute operation without freaking out Not dom compliant browsers are all microsoft browsers in quirks mode and ie6 and ie7 to some degree in standards mode and pretty much every browser who cannot create ranges (older mobile browsers etc...) We dont do a full browser detection here because it probably is safer to test for existing features to make an assumption about the browsers capabilities

nodeIdOrName(elem)
node id or name, determines the valid form identifier of a node depending on its uniqueness Usually the id is chosen for an elem, but if the id does not exist we try a name fallback. If the passed element has a unique name we can use that one as subsequent identifier.
Parameters:
{String} elem

outerHTML(item, markup, preserveFocus,)
outerHTML replacement which works cross browserlike but still is speed optimized
Parameters:
item
the item to be replaced
markup
the markup for the replacement
preserveFocus,
tries to preserve the focus within the outerhtml operation if set to true a focus preservation algorithm based on document.activeElement is used to preserve the focus at the exactly same location as it was

replaceElement(item, evalNode)
for performance reasons we work with replaceElement and replaceElements here after measuring performance it has shown that passing down an array instead of a single node makes replaceElement twice as slow, however a single node case is the 95% case
Parameters:
item
evalNode

replaceElements(item, evalNodes)
replaces an element with another element or a set of elements
Parameters:
item
the item to be replaced
evalNodes
the elements

runScripts(item, xmlData)
Run through the given Html item and execute the inline scripts (IE doesn't do this by itself)
Parameters:
{Node} item
xmlData

setAttribute(node, attr, val)
bugfixing for ie6 which does not cope properly with setAttribute
Parameters:
node
attr
val

Documentation generated by JsDoc Toolkit 2.1.0 on Thu Mar 31 2016 20:57:59 GMT-0000 (GMT)