UNPKG

siesta-lite

Version:

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

104 lines (76 loc) 3.18 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 */ Class(&#39;Siesta.Util.XMLNode&#39;, { has : { children : Joose.I.Array, tag : { required : true }, attributes : Joose.I.Object, textContent : null, escapeTable : { init : { &#39;&amp;&#39; : &#39;&amp;amp;&#39;, &#39;&lt;&#39; : &#39;&amp;lt;&#39;, &#39;&gt;&#39; : &#39;&amp;gt;&#39;, &#39;&quot;&#39; : &#39;&amp;quot;&#39; } } }, methods : { escapeXml : function (s) { var me = this return typeof s != &#39;string&#39; ? s : s.replace(/[&amp;&lt;&gt;&quot;]/g, function (match) { return me.escapeTable[ match ] }) }, toString : function () { var me = this var childrenContent = [] Joose.A.each(this.children, function (child) { childrenContent.push(child.toString()) }) var attributesContent = [] Joose.O.each(this.attributes, function (value, name) { attributesContent.push(name + &#39;=&quot;&#39; + me.escapeXml(value) + &#39;&quot;&#39;) }) // to have predictable order of attributes in tests attributesContent.sort() attributesContent.unshift(this.tag) return &#39;&lt;&#39; + attributesContent.join(&#39; &#39;) + &#39;&gt;&#39; + (this.textContent != null ? this.escapeXml(this.textContent) : &#39;&#39;) + childrenContent.join(&#39;&#39;) + &#39;&lt;/&#39; + this.tag + &#39;&gt;&#39; }, appendChild : function (child) { if (child instanceof Siesta.Util.XMLNode) child.parent = this else child = new Siesta.Util.XMLNode(Joose.O.extend(child, { parent : this })) this.children.push(child) return child }, setAttribute : function (name, value) { this.attributes[ name ] = value } } }) </pre> </body> </html>