UNPKG

siesta-lite

Version:

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

117 lines (83 loc) 3.54 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.Content.Preset&#39;, { has : { preload : Joose.I.Array, resources : Joose.I.Array }, methods : { initialize : function () { var me = this Joose.A.each(this.preload, function (preloadDesc) { me.addResource(preloadDesc) }) }, isCSS : function (url) { return /\.css(\?.*)?$/i.test(url) }, getResourceFromDescriptor : function (desc) { var constructor, config var CSS if (typeof desc == &#39;string&#39;) { constructor = this.isCSS(desc) ? Siesta.Content.Resource.CSS : Siesta.Content.Resource.JavaScript config = { url : desc } } else if (desc.text) { constructor = Siesta.Content.Resource.JavaScript config = { content : desc.text } } else { if (!desc.url &amp;&amp; !desc.content) throw &quot;Incorrect preload descriptor:&quot; + desc constructor = desc.type &amp;&amp; desc.type == &#39;css&#39; || this.isCSS(desc.url) ? Siesta.Content.Resource.CSS : Siesta.Content.Resource.JavaScript config = {} if (desc.url) config.url = desc.url if (desc.content) config.content = desc.content if (desc.instrument) config.instrument = desc.instrument if (desc.isEcmaModule) config.isEcmaModule = desc.isEcmaModule } return new constructor(config) }, addResource : function (desc) { var resource = (desc instanceof Siesta.Content.Resource) &amp;&amp; desc || this.getResourceFromDescriptor(desc) this.resources.push(resource) return resource }, eachResource : function (func, scope) { return Joose.A.each(this.resources, func, scope || this) }, // deprecated - seems preset doesn&#39;t need to know about scope providers prepareScope : function (scopeProvider, contentManager) { this.eachResource(function (resource) { if (contentManager.hasContentOf(resource)) scopeProvider.addPreload({ type : (resource instanceof Siesta.Content.Resource.CSS) ? &#39;css&#39; : &#39;js&#39;, content : contentManager.getContentOf(resource) }) else scopeProvider.addPreload(resource.asDescriptor()) }) } } }) </pre> </body> </html>