UNPKG

siesta-lite

Version:

Stress-free JavaScript unit testing and functional testing tool, works in NodeJS and browsers

133 lines (101 loc) 4.7 kB
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>The source code</title> <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" /> <script type="text/javascript" src="../resources/prettify/prettify.js"></script> <style type="text/css"> .highlight { display: block; background-color: #ddd; } </style> <script type="text/javascript"> function highlight() { document.getElementById(location.hash.replace(/#/, "")).className = "highlight"; } </script> </head> <body onload="prettyPrint(); highlight();"> <pre class="prettyprint lang-js">/* Siesta 5.6.1 Copyright(c) 2009-2022 Bryntum AB https://bryntum.com/contact https://bryntum.com/products/siesta/license */ Role(&#39;Siesta.Util.Role.CanInstallCQRootPseudo&#39;, { methods : { // add :root pseudo CQ selector to be able to identify &#39;root&#39; level components that don&#39;t have // parent containers. value is 1-based installRootPseudoCQ : function (Ext) { if (!Ext) return var CQ = Ext.ComponentQuery if (!CQ) return var pseudos = CQ.pseudos if (!pseudos.root || !pseudos.root.__IS_ROOT_PSEUDO_OVERRIDE__) { var rootPseudo = function (items, value) { var i = 0, l = items.length, c, result = []; var findAllRoots = value === undefined if (!findAllRoots) { value = Number(value) - 1; } for (; i &lt; l; i++) { c = items[i].up(); var hasParentContainer = c &amp;&amp; c.contains &amp;&amp; c.contains(items[i]); if (!hasParentContainer) { result.push(items[i]); } } if (!findAllRoots) { result = result[value] ? [result[value]] : []; } return result; } rootPseudo.__IS_ROOT_PSEUDO_OVERRIDE__ = true pseudos.root = rootPseudo } if (!pseudos[ &quot;ariadne-nth-child&quot; ]) { pseudos[ &quot;ariadne-nth-child&quot; ] = function (items, selector) { var result = [] var pos = Number(selector) - 1 var len = items.length for (var i = 0; i &lt; len; i++) { var cmp = items[ i ] var parentCt = cmp.getRefOwner &amp;&amp; cmp.getRefOwner() || cmp.ownerCt var parentCtItems = parentCt &amp;&amp; parentCt.items // parentCt could be an Ext ActionColumn which has &#39;items&#39; but isn&#39;t a true container if (parentCtItems &amp;&amp; parentCtItems.getCount) { var innerItemsLen = parentCtItems.getCount() if (pos &lt; innerItemsLen) { if (parentCtItems.getAt(pos) === cmp) result.push(cmp) } else { var refItems = parentCt.getRefItems() if (refItems[ pos ] === cmp) result.push(cmp) } } } return result; } } var version = Ext.getVersion &amp;&amp; Ext.getVersion(&#39;ext&#39;) if (version &amp;&amp; version.major == 4 &amp;&amp; !CQ.__CQ4_PATCHED__) { // install workarounds for ExtJS 4 which does not pay any attention to attribute values // escaping/unescaping Ext.dom.Query.operators[ &#39;=&#39; ] = function (a, b) { return a == Siesta.Sizzle.unescape(b) } var prevQuery = CQ.query // also ExtJS4 CQ just &quot;split&quot; the query by &quot;,&quot; even that comma can be part of string expression CQ.query = function (query, root) { if (/\\,/.test(query)) return prevQuery.call(this, { split : function () { return [ query ] } }, root) else return prevQuery.call(this, query, root) } CQ.__CQ4_PATCHED__ = true } } } }); </pre> </body> </html>