Permalink
Browse files

Resolving #54

  • Loading branch information...
1 parent 257edc8 commit e51e72eafa7ab2d8b6e72ca9ba628f3479ac5c7a @krasimir committed Mar 3, 2014
View
1 Gruntfile.js
@@ -70,6 +70,7 @@ module.exports = function(grunt) {
'tests/organic/*.js',
'tests/experimental/move.selector.up.spec.js',
'tests/experimental/same.property.diff.value.spec.js',
+ 'tests/experimental/error.reporting.spec.js',
'!tests/common/api.import.spec.js',
'!tests/common/compile-and-save.spec.js',
'!tests/common/minify.spec.js',
View
112 client-side/build/absurd.js
@@ -1,4 +1,4 @@
-/* version: 0.3.136, born: 3-2-2014 15:31 */
+/* version: 0.3.137, born: 3-2-2014 15:49 */
var Absurd = (function(w) {
var lib = {
api: {},
@@ -1282,70 +1282,76 @@ lib.api.add = function(API) {
var add = function(rules, stylesheet, opts) {
- toRegister = [];
- API.numOfAddedRules += 1;
+ try {
- if(typeof stylesheet === 'object' && typeof opts === 'undefined') {
- options = {
- combineSelectors: typeof stylesheet.combineSelectors != 'undefined' ? stylesheet.combineSelectors : options.combineSelectors,
- preventCombining: options.preventCombining.concat(stylesheet.preventCombining || [])
- };
- stylesheet = null;
- }
- if(typeof opts != 'undefined') {
- options = {
- combineSelectors: opts.combineSelectors || options.combineSelectors,
- preventCombining: options.preventCombining.concat(opts.preventCombining || [])
- };
- }
+ toRegister = [];
+ API.numOfAddedRules += 1;
- var typeOfPreprocessor = API.defaultProcessor.type, uid;
-
- for(var selector in rules) {
- addRule(selector, rules[selector], stylesheet || "mainstream");
- }
-
- // looping through the rules for registering
- for(var i=0; i<toRegister.length; i++) {
- var stylesheet = toRegister[i].stylesheet,
- selector = toRegister[i].selector,
- props = toRegister[i].props,
- allRules = API.getRules(stylesheet);
- var pc = options && options.preventCombining ? '|' + options.preventCombining.join('|') : '';
- var uid = pc.indexOf('|' + selector) >= 0 ? '~~' + API.numOfAddedRules + '~~' : '';
- // overwrite already added value
- var current = allRules[uid + selector] || {};
- for(var propNew in props) {
- var value = props[propNew];
- propNew = uid + propNew;
- if(typeof value != 'object') {
- if(typeOfPreprocessor == "css") {
- // appending values
- if(value.toString().charAt(0) === "+") {
- if(current && current[propNew]) {
- current[propNew] = current[propNew] + ", " + value.substr(1, value.length-1);
- } else {
- current[propNew] = value.substr(1, value.length-1);
- }
- } else if(value.toString().charAt(0) === ">") {
- if(current && current[propNew]) {
- current[propNew] = current[propNew] + " " + value.substr(1, value.length-1);
+ if(typeof stylesheet === 'object' && typeof opts === 'undefined') {
+ options = {
+ combineSelectors: typeof stylesheet.combineSelectors != 'undefined' ? stylesheet.combineSelectors : options.combineSelectors,
+ preventCombining: options.preventCombining.concat(stylesheet.preventCombining || [])
+ };
+ stylesheet = null;
+ }
+ if(typeof opts != 'undefined') {
+ options = {
+ combineSelectors: opts.combineSelectors || options.combineSelectors,
+ preventCombining: options.preventCombining.concat(opts.preventCombining || [])
+ };
+ }
+
+ var typeOfPreprocessor = API.defaultProcessor.type, uid;
+
+ for(var selector in rules) {
+ addRule(selector, rules[selector], stylesheet || "mainstream");
+ }
+
+ // looping through the rules for registering
+ for(var i=0; i<toRegister.length; i++) {
+ var stylesheet = toRegister[i].stylesheet,
+ selector = toRegister[i].selector,
+ props = toRegister[i].props,
+ allRules = API.getRules(stylesheet);
+ var pc = options && options.preventCombining ? '|' + options.preventCombining.join('|') : '';
+ var uid = pc.indexOf('|' + selector) >= 0 ? '~~' + API.numOfAddedRules + '~~' : '';
+ // overwrite already added value
+ var current = allRules[uid + selector] || {};
+ for(var propNew in props) {
+ var value = props[propNew];
+ propNew = uid + propNew;
+ if(typeof value != 'object') {
+ if(typeOfPreprocessor == "css") {
+ // appending values
+ if(value.toString().charAt(0) === "+") {
+ if(current && current[propNew]) {
+ current[propNew] = current[propNew] + ", " + value.substr(1, value.length-1);
+ } else {
+ current[propNew] = value.substr(1, value.length-1);
+ }
+ } else if(value.toString().charAt(0) === ">") {
+ if(current && current[propNew]) {
+ current[propNew] = current[propNew] + " " + value.substr(1, value.length-1);
+ } else {
+ current[propNew] = value.substr(1, value.length-1);
+ }
} else {
- current[propNew] = value.substr(1, value.length-1);
+ current[propNew] = value;
}
} else {
current[propNew] = value;
}
- } else {
- current[propNew] = value;
+
}
-
}
+ allRules[uid + selector] = current;
}
- allRules[uid + selector] = current;
- }
return API;
+
+ } catch(err) {
+ throw new Error("Error adding: " + JSON.stringify(rules));
+ }
}
return add;
}
View
4 client-side/build/absurd.min.js
@@ -1,2 +1,2 @@
-var Absurd=function(){var b={api:{},helpers:{},plugins:{},processors:{css:{plugins:{}},html:{plugins:{},helpers:{}},component:{plugins:{}}}},d=function(a){return a.indexOf("css/CSS.js")>0||"/../CSS.js"==a?b.processors.css.CSS:a.indexOf("html/HTML.js")>0?b.processors.html.HTML:a.indexOf("component/Component.js")>0?b.processors.component.Component:"js-beautify"==a?{html:function(a){return a}}:"./helpers/PropAnalyzer"==a?b.processors.html.helpers.PropAnalyzer:"../../helpers/TransformUppercase"==a?b.helpers.TransformUppercase:"./helpers/TemplateEngine"==a?b.processors.html.helpers.TemplateEngine:"../helpers/Extend"==a?b.helpers.Extend:"../helpers/Clone"==a?b.helpers.Clone:"../helpers/Prefixes"==a||"/../../../helpers/Prefixes"==a?b.helpers.Prefixes:a==e+"/../../../../"?Absurd:function(){}},e="",f=function(a,b){!function c(){a.length>0&&a.shift().apply(b||{},[c].concat(Array.prototype.slice.call(arguments,0)))}()},g=function(a){var b={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],area:[1,"<map>","</map>"],param:[1,"<object>","</object>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],body:[0,"",""],_default:[1,"<div>","</div>"]};b.optgroup=b.option,b.tbody=b.tfoot=b.colgroup=b.caption=b.thead,b.th=b.td;var c=/<\s*\w.*?>/g.exec(a),d=document.createElement("div");if(null!=c){var e=c[0].replace(/</g,"").replace(/>/g,"").split(" ")[0];if("body"===e.toLowerCase()){var f=(document.implementation.createDocument("http://www.w3.org/1999/xhtml","html",null),document.createElement("body"));d.innerHTML=a.replace(/<body/g,"<div").replace(/<\/body>/g,"</div>");var g=d.firstChild.attributes;f.innerHTML=a;for(var h=0;h<g.length;h++)f.setAttribute(g[h].name,g[h].value);return f}var d,i=b[e]||b._default;a=i[1]+a+i[2],d.innerHTML=a;for(var j=i[0]+1;j--;)d=d.lastChild}else d.innerHTML=a,d=d.lastChild;return d},h=function(a,b,c){return a.addEventListener?(a.addEventListener(b,c,!1),!0):a.attachEvent?a.attachEvent("on"+b,c):void 0},i=function(a){for(var b,c=a.childNodes,d=c.length,e=0,f=/^\s*$/;d>e;e++)b=c[e],3==b.nodeType&&f.test(b.nodeValue)&&(a.removeChild(b),e--,d--);return a},j=function(b,c,d){for(var e=document.createElement(b),f=0;f<c.length,a=c[f];f++)e.setAttribute(a.name,a.value);return e.innerHTML=d,e},k=function(a,b){return b=b===!1?document:b||this.el||document,b.querySelector(a)},l=function(a,b){return b=b===!1?document:b||this.el||document,b.querySelectorAll(a)},m=function(a,b){return b=b||this.el,b&&b.currentStyle?b.currentStyle[a]:window.getComputedStyle?document.defaultView.getComputedStyle(b,null).getPropertyValue(a):null},n=function(a,b){if(b=b||this.el,b.classList)b.classList.add(a);else{var c=b.className;c.indexOf(a)<0&&(""==c?b.className=a:b.className+=" "+a)}return this},q=function(a,b){if(b=b||this.el,b.classList)b.classList.remove(a);else{for(var c=b.className.split(" "),d=[],e=0;e<c.length;e++)c[e]!=a&&d.push(c[e]);b.className=d.join(" ")}return this},r=function(a,b,c){c=c||this.el;for(var d=c.className.split(" "),e=!1,f=0;f<d.length;f++)d[f]==a&&(e=!0,d[f]=b);return e?(c.className=d.join(" "),this):n(b,c)},s=function(a,b){if(b=b||this.el,b.classList)b.classList.toggle(a);else{for(var c=b.className.split(" "),d=-1,e=c.length;e--;)c[e]===a&&(d=e);d>=0?c.splice(d,1):c.push(a),b.className=c.join(" ")}return this},t=function(a,c,d,e){var o=b.helpers.Extend({__name:a},e),p=b.helpers.Extend,t=[];o.listeners=t,o.on=function(a,b,c){return t[a]||(t[a]=[]),t[a].push({callback:b,scope:c}),this},o.off=function(a,b){return t[a]?(b||(t[a]=[]),this):this},o.dispatch=function(a,b,c){if(!b||"object"!=typeof b||b instanceof Array||(b.target=this),t[a])for(var e=0;e<t[a].length;e++){var f=t[a][e].callback;f.apply(c||t[a][e].scope||{},[b])}return this[a]&&"function"==typeof this[a]&&this[a](b),d&&d.dispatch(a,b),this};var u={};o.set=function(a,b){return u[a]=b,this},o.get=function(a){return u[a]};var v=!1;o.__handleCSS=function(b){return this.css?c.flush().add(this.css).compile(function(c,d){if(v)v.raw!==d&&(v.raw=d,v.element.innerHTML=d);else{var e=j("style",[{name:"id",value:a+"-css"},{name:"type",value:"text/css"}],d);(k("head")||k("body")).appendChild(e),v={raw:d,element:e}}b()}):b(),this},o.applyCSS=function(a,b,c){if(this.html&&"string"==typeof this.html&&!b){var d={};d[this.html]=a,a=d}return this.css=a,c||this.populate(),this};var w=!1;o.__mergeDOMElements=function(a,b){if(i(a),i(b),"undefined"!=typeof a&&"undefined"!=typeof b&&!a.isEqualNode(b)){if(a.nodeName!==b.nodeName)return a.parentNode&&a.parentNode.replaceChild(b,a),void 0;if(a.nodeValue!==b.nodeValue&&(a.nodeValue=b.nodeValue),a.attributes){for(var c,d,e=a.attributes,f=b.attributes,g={},h=0;h<e.length,c=e[h];h++){for(var j=0;j<f.length,d=f[j];j++)c.name===d.name&&(a.setAttribute(c.name,d.value),g[c.name]=!0);g[c.name]||a.removeAttribute(c.name)}for(var h=0;h<f.length,d=f[h];h++)g[d.name]||a.setAttribute(d.name,d.value)}var k=[];if(a.childNodes.length>=b.childNodes.length)for(var h=0;h<a.childNodes.length;h++)b.childNodes[h]||b.appendChild(document.createTextNode("")),k.push([a.childNodes[h],b.childNodes[h]]);else for(var h=0;h<b.childNodes.length;h++)a.appendChild(document.createTextNode("")),k.push([a.childNodes[h],b.childNodes[h]]);for(var h=0;h<k.length;h++)o.__mergeDOMElements(k[h][0],k[h][1])}},o.__handleHTML=function(a){var b=this,d=function(){c.flush().morph("html").add(w).compile(function(c,d){b.el?o.__mergeDOMElements(b.el,g(d)):b.el=g(d),a()},b)};if(this.html)if("string"==typeof this.html){if(!this.el){var e=k(this.html);e&&(this.el=e,w={"":this.el.outerHTML.replace(/&lt;/g,"<").replace(/&gt;/g,">")})}d()}else"object"==typeof this.html?(w=p({},this.html),d()):a();else a();return this},o.applyHTML=function(a,b){return this.html=a,b||this.populate(),this};var x=!1;o.__append=function(a){return!x&&this.el&&this.get("parent")&&(x=!0,this.get("parent").appendChild(this.el)),a(),this};var y={events:{}};o.__handleEvents=function(a){if(this.el){var b=this,c=function(a){var c=a.getAttribute("data-absurd-event");if(c=c.split(":"),c.length>=2){var d=c[0],e=c[1];c.splice(0,2);var f=c;(!y.events[d]||y.events[d].indexOf(a)<0)&&(y.events[d]||(y.events[d]=[]),y.events[d].push(a),h(a,d,function(a){if("function"==typeof b[e]){var c=b[e];c.apply(b,[a].concat(f))}}))}};this.el.hasAttribute&&this.el.hasAttribute("data-absurd-event")&&c(this.el);for(var d=this.el.querySelectorAll?this.el.querySelectorAll("[data-absurd-event]"):[],e=0;e<d.length;e++)c(d[e])}return a(),this},o.__getAnimAndTransEndEventName=function(a){if(a){var b,c={animation:["animationend","transitionend"],OAnimation:["oAnimationEnd","oTransitionEnd"],MozAnimation:["animationend","transitionend"],WebkitAnimation:["webkitAnimationEnd","webkitTransitionEnd"]};for(b in c)if(void 0!==a.style[b])return c[b]}},o.onAnimationEnd=function(a,b){1==arguments.length&&(b=a,a=this.el);var c=this,d=o.__getAnimAndTransEndEventName(a);return d?(this.addEventListener(a,d[0],function(a){b.apply(c,[a])}),void 0):(b.apply(this,[{error:"Animations not supported."}]),void 0)},o.onTransitionEnd=function(a,b){1==arguments.length&&(b=a,a=this.el);var c=this,d=o.__getAnimAndTransEndEventName(a);return d?(this.addEventListener(a,d[1],function(a){b.apply(c,[a])}),void 0):(b.apply(this,[{error:"Animations not supported."}]),void 0)};var z={funcs:{},index:0};o.__handleAsyncFunctions=function(a){if(this.el){var b=[];if(this.el.hasAttribute&&this.el.hasAttribute("data-absurd-async"))b.push(this.el);else for(var c=this.el.querySelectorAll?this.el.querySelectorAll("[data-absurd-async]"):[],d=0;d<c.length;d++)b.push(c[d]);if(0===b.length)a();else{var e=this;!function f(){if(0===b.length)a();else{var c=b.shift(),d=c.getAttribute("data-absurd-async"),h=function(a){"string"==typeof a?c.parentNode.replaceChild(g(a),c):c.parentNode.replaceChild(a,c),f()};"function"==typeof e[z.funcs[d].name]?e[z.funcs[d].name].apply(e,[h].concat(z.funcs[d].args)):"function"==typeof z.funcs[d].func&&z.funcs[d].func.apply(e,[h].concat(z.funcs[d].args))}}()}}else a();return this},o.async=function(){var a=Array.prototype.slice.call(arguments,0),b=a.shift(),c="_"+z.index++;return z.funcs[c]={args:a,name:b},'<script data-absurd-async="'+c+'"></script>'},o.child=function(){var a=Array.prototype.slice.call(arguments,0),b=this.get("children"),c=b&&b[a.shift()],d="_"+z.index++;return z.funcs[d]={args:a,func:function(a){c.populate({callback:function(b){a(b.html.element)}})}},'<script data-absurd-async="'+d+'"></script>'},o.wire=function(a){return c.components.events.on(a,this[a]||function(){},this),this};var A=!1;return o.populate=function(a){return A?void 0:(A=!0,f([o.__handleCSS,o.__handleHTML,o.__append,o.__handleEvents,o.__handleAsyncFunctions,function(){A=!1,z={funcs:{},index:0};var b={css:v,html:{element:this.el}};this.dispatch("populated",b),a&&"function"==typeof a.callback&&a.callback(b)}],this),this)},o.str2DOMElement=g,o.addEventListener=h,o.queue=f,o.qs=k,o.qsa=l,o.getStyle=m,o.addClass=n,o.removeClass=q,o.replaceClass=r,o.toggleClass=s,o.compileHTML=function(a,b,d){c.flush().morph("html").add(a).compile(b,d)},o.compileCSS=function(a,b,d){c.flush().add(a).compile(b,d)},o.delay=function(a,b,c){var d=this;setTimeout(function(){b.apply(d,c)},a)},o},u=function(a){a.di.register("is",{appended:function(a){return"undefined"==typeof a&&(a=this.host.html),k(a)?!0:!1}}),a.di.register("router",{routes:[],mode:null,root:"/",getFragment:function(){var a="";if("history"===this.mode){if(!location)return"";a=this.clearSlashes(decodeURI(location.pathname+location.search)),a=a.replace(/\?(.*)$/,""),a="/"!=this.root?a.replace(this.root,""):a}else{if(!window)return"";var b=window.location.href.match(/#(.*)$/);a=b?b[1]:""}return this.clearSlashes(a)},clearSlashes:function(a){return a.toString().replace(/\/$/,"").replace(/^\//,"")},add:function(a,b){return"function"==typeof a&&(b=a,a=""),this.routes.push({re:a,handler:b}),this},remove:function(a){for(var b,c=0;c<this.routes.length,b=this.routes[c];c++)if(b.handler===a||b.re===a)return this.routes.splice(c,1),this;return this},flush:function(){return this.routes=[],this.mode=null,this.root="/",this},config:function(a){return this.mode=a&&a.mode&&"history"==a.mode&&history.pushState?"history":"hash",this.root=a&&a.root?"/"+this.clearSlashes(a.root)+"/":"/",this},listen:function(){var a=this,b=a.getFragment(),c=function(){b!==a.getFragment()&&(b=a.getFragment(),a.check(b))};return clearInterval(this.interval),this.interval=setInterval(c,50),this},check:function(a){for(var b=a||this.getFragment(),c=0;c<this.routes.length;c++){var d=b.match(this.routes[c].re);if(d)return d.shift(),this.routes[c].handler.apply(this.host||{},d),this}return this},navigate:function(a){return a=a?a:"","history"===this.mode?history.pushState(null,null,this.root+this.clearSlashes(a)):(window.location.href.match(/#(.*)$/),window.location.href=window.location.href.replace(/#(.*)$/,"")+"#"+a),this}}),a.di.register("ajax",{request:function(a){"string"==typeof a&&(a={url:a}),a.url=a.url||"",a.method=a.method||"get",a.data=a.data||{};var b=function(a,b){var c,d=[];for(var e in a)d.push(e+"="+encodeURIComponent(a[e]));return c=d.join("&"),""!=c?b?b.indexOf("?")<0?"?"+c:"&"+c:c:""},c={host:this.host||{},process:function(a){var c=this;return this.xhr=null,window.ActiveXObject?this.xhr=new ActiveXObject("Microsoft.XMLHTTP"):window.XMLHttpRequest&&(this.xhr=new XMLHttpRequest),this.xhr&&(this.xhr.onreadystatechange=function(){if(4==c.xhr.readyState&&200==c.xhr.status){var b=c.xhr.responseText;a.json===!0&&"undefined"!=typeof JSON&&(b=JSON.parse(b)),c.doneCallback&&c.doneCallback.apply(c.host,[b,c.xhr])}else 4==c.xhr.readyState&&c.failCallback&&c.failCallback.apply(c.host,[c.xhr]);c.alwaysCallback&&c.alwaysCallback.apply(c.host,[c.xhr])},"get"==a.method?this.xhr.open("GET",a.url+b(a.data,a.url),!0):(this.xhr.open(a.method,a.url,!0),this.setHeaders({"X-Requested-With":"XMLHttpRequest","Content-type":"application/x-www-form-urlencoded"})),a.headers&&"object"==typeof a.headers&&this.setHeaders(a.headers),setTimeout(function(){"get"==a.method?c.xhr.send():c.xhr.send(b(a.data))},20)),this},done:function(a){return this.doneCallback=a,this},fail:function(a){return this.failCallback=a,this},always:function(a){return this.alwaysCallback=a,this},setHeaders:function(a){for(var b in a)this.xhr&&this.xhr.setRequestHeader(b,a[b])}};return c.process(a)}});var b=function(a,c){var d=b.prototype.host,e={el:null};switch(typeof a){case"undefined":e.el=d.el;break;case"string":c=c&&"string"==typeof c?k.apply(d,[c]):c,e.el=k(a,c||d.el||document);break;case"object":if("undefined"==typeof a.nodeName){var f=function(a,b){b=b||this;for(var c in b)"undefined"!=typeof b[c].el?b[c]=b[c].val(a):"object"==typeof b[c]&&(b[c]=f(a,b[c]));return delete b.val,b},g={val:f};for(var h in a)g[h]=b.apply(this,[a[h]]);return g}e.el=a}return e.val=function(a){if(!this.el)return null;var b=!!a,d=function(a){return b?(this.el.value=a,e):this.el.value};switch(this.el.nodeName.toLowerCase()){case"input":var f=this.el.getAttribute("type");if("radio"!=f&&"checkbox"!=f)return d.apply(this,[a]);for(var g=l('[name="'+this.el.getAttribute("name")+'"]',c),h=[],i=0;i<g.length;i++)b&&g[i].checked&&g[i].value!==a?g[i].removeAttribute("checked"):b&&g[i].value===a?(g[i].setAttribute("checked","checked"),g[i].checked="checked"):g[i].checked&&h.push(g[i].value);if(!b)return"radio"==f?h[0]:h;break;case"textarea":return d.apply(this,[a]);case"select":if(!b)return this.el.value;for(var j=l("option",this.el),i=0;i<j.length;i++)j[i].getAttribute("value")===a?this.el.selectedIndex=i:j[i].removeAttribute("selected");break;default:if(!b)return"undefined"!=typeof this.el.textContent?this.el.textContent:"undefined"!=typeof this.el.innerText?typeof this.el.innerText:this.el.innerHTML;this.el.innerHTML=a}return b?e:null},e.dom=function(a,c){return b(a,c||e.el)},e};a.di.register("dom",b)},w=function(){return function(a){var d=function(a,b){for(var c in b)hasOwnProperty.call(b,c)&&(a[c]=b[c]);return a},e={defaultProcessor:b.processors.css.CSS()},f={},h={},i={},j={};e.getRules=function(a){return"undefined"==typeof a?f:("undefined"==typeof f[a]&&(f[a]=[]),f[a])},e.getPlugins=function(){return i},e.getStorage=function(){return h},e.flush=function(){return f={},h=[],j={},e.defaultProcessor=b.processors.css.CSS(),e},e.import=function(){return e.callHooks("import",arguments)?e:e},e.addHook=function(a,b){j[a]||(j[a]=[]);for(var d=!1,e=0;c=j[a][e];e++)c===b&&(d=!0);d===!1?j[a].push(b):null},e.callHooks=function(a,b){if(j[a])for(var d=0;c=j[a][d];d++)if(c.apply(e,b)===!0)return!0;return!1},e.numOfAddedRules=0,e.components=function(a){var c=b.helpers.Extend,d=b.helpers.Clone,e={},f=[],g=c({},t()),h={};return function(a){window&&(window.addEventListener?window.addEventListener("load",a):window.attachEvent&&window.attachEvent("onload",a))}(function(){h.broadcast("ready")}),h={events:g,register:function(b,h){return e[b]=function(){var e=c({},t(b,a,g,d(h)));return a.di.resolveObject(e),f.push(e),"function"==typeof e.constructor&&e.constructor.apply(e,Array.prototype.slice.call(arguments,0)),e}},get:function(a){if(e[a])return e[a];throw new Error("There is no component with name '"+a+"'.")},remove:function(a){return e[a]?(delete e[a],!0):!1},list:function(){var a=[];for(var b in e)a.push(b);return a},flush:function(){return e={},f=[],this},broadcast:function(a,b){for(var c=0;c<f.length,instance=f[c];c++)"function"==typeof instance[a]&&instance[a](b);return this}}}(e),e.component=function(a){return function(b,c){return"undefined"==typeof c?a.components.get(b):a.components.register(b,c)}}(e),e.di=b.DI(e),u(e),e.compile=function(a,b){if(e.callHooks("compile",arguments))return e;var c={combineSelectors:!0,minify:!1,processor:e.defaultProcessor,keepCamelCase:!1,api:e};b=d(c,b||{}),b.processor(e.getRules(),a||function(){},b),e.flush()};for(var k in b.api)"compile"!==k&&(e[k]=b.api[k](e),e[k]=function(a){return function(){var c=b.api[a](e);return e.callHooks(a,arguments)?e:c.apply(e,arguments)}}(k));for(var l in b.processors.css.plugins)e.plugin(l,b.processors.css.plugins[l]());return"function"==typeof a&&a(e),"undefined"!=typeof Organic&&Organic.init(e),e.utils={str2DOMElement:g},e}};b.DI=function(){var a={dependencies:{},register:function(a,b){return this.dependencies[a]=b,this},resolve:function(){var a,b,c,d=this,e=!1;"string"==typeof arguments[0]?(a=arguments[1],b=arguments[0].replace(/ /g,"").split(","),c=arguments[2]||{}):(a=arguments[0],b=a.toString().match(/^function\s*[^\(]*\(\s*([^\)]*)\)/m)[1].replace(/ /g,"").split(","),c=arguments[1]||{});for(var f=0;f<b.length;f++)"undefined"!=typeof this.dependencies[b[f]]&&(e=!0);return e?function(){for(var e=[],f=Array.prototype.slice.call(arguments,0),g=0;g<b.length;g++){var h=b[g];if("undefined"!=typeof d.dependencies[h]){var i=d.dependencies[h];"function"==typeof i?i.prototype.host=c:"object"==typeof i&&(i.host=c),e.push(i)}else e.push(f.shift())}return a.apply(c,e)}:a},resolveObject:function(a){if("object"==typeof a)for(var b in a)"function"==typeof a[b]?a[b]=this.resolve(a[b],a):a[b]instanceof Array&&2==a[b].length&&"string"==typeof a[b][0]&&"function"==typeof a[b][1]&&(a[b]=this.resolve(a[b][0],a[b][1],a));return this},flush:function(){return this.dependencies={},this}};return a},b.api.add=function(a){var b=(d("../helpers/Extend"),d("../helpers/Prefixes")),c=[],e={combineSelectors:!0,preventCombining:["@font-face"]},f=function(c,d,e,f,h){var i=b.nonPrefixProp(d),j=a.getPlugins()[i.prop];if("undefined"!=typeof j){var k=j(a,e,i.prefix);return k&&g(c,k,f,h),!0}return!1},g=function(a,d,h,i){if(h=h||"mainstream",null!==d&&"undefined"!=typeof d&&d!==!1)if(i||a||(a=""),/, ?/g.test(a)&&e.combineSelectors)for(var j=a.replace(/, /g,",").split(","),k=0;k<j.length,p=j[k];k++)g(p,d,h,i);else if(!f(null,a,d,h,i))if("undefined"==typeof d.length||"object"!=typeof d){var l={},m=a,n={},o={};for(var q in d){d[q]&&"undefined"!=typeof d[q].classify&&d[q].classify===!0&&(d[q]="undefined"!=typeof d[q].toJSON?d[q].toJSON():d[q].toString());var r=typeof d[q];"object"!==r&&"function"!==r&&d[q]!==!1&&d[q]!==!0?f(a,q,d[q],h,i)===!1&&(m=0===m.indexOf("^")?m.substr(1,m.length-1)+("undefined"!=typeof i?" "+i:""):"undefined"!=typeof i?i+" "+a:a,l[q]=d[q],b.addPrefixes(q,l)):"object"===r?n[q]=d[q]:"function"===r&&(o[q]=d[q])}c.push({selector:m,props:l,stylesheet:h});for(var q in n)if(":"===q.charAt(0))g(a+q,n[q],h,i);else if(/&/g.test(q))if(/, ?/g.test(q)&&e.combineSelectors)for(var j=q.replace(/, /g,",").split(","),k=0;k<j.length,p=j[k];k++)p.indexOf("&")>=0?g(p.replace(/&/g,a),n[q],h,i):g(p,n[q],h,"undefined"!=typeof i?i+" "+a:a);else g(q.replace(/&/g,a),n[q],h,i);else 0===q.indexOf("@media")||0===q.indexOf("@supports")?g(a,n[q],q,i):0===a.indexOf("@media")||0===q.indexOf("@supports")?g(q,n[q],a,i):0===a.indexOf("^")?g(a.substr(1,a.length-1)+("undefined"!=typeof i?" "+i:"")+" "+q,n[q],h):f(a,q,n[q],h,i)===!1&&g(q,n[q],h,(i?i+" ":"")+a);for(var q in o){var s={};s[q]=o[q](),g(a,s,h,i)}}else for(var k=0;k<d.length,q=d[k];k++)g(a,q,h,i)},h=function(b,d,f){c=[],a.numOfAddedRules+=1,"object"==typeof d&&"undefined"==typeof f&&(e={combineSelectors:"undefined"!=typeof d.combineSelectors?d.combineSelectors:e.combineSelectors,preventCombining:e.preventCombining.concat(d.preventCombining||[])},d=null),"undefined"!=typeof f&&(e={combineSelectors:f.combineSelectors||e.combineSelectors,preventCombining:e.preventCombining.concat(f.preventCombining||[])});var h,i=a.defaultProcessor.type;for(var j in b)g(j,b[j],d||"mainstream");for(var k=0;k<c.length;k++){var d=c[k].stylesheet,j=c[k].selector,l=c[k].props,m=a.getRules(d),n=e&&e.preventCombining?"|"+e.preventCombining.join("|"):"",h=n.indexOf("|"+j)>=0?"~~"+a.numOfAddedRules+"~~":"",o=m[h+j]||{};for(var p in l){var q=l[p];p=h+p,"object"!=typeof q&&(o[p]="css"==i?"+"===q.toString().charAt(0)?o&&o[p]?o[p]+", "+q.substr(1,q.length-1):q.substr(1,q.length-1):">"===q.toString().charAt(0)?o&&o[p]?o[p]+" "+q.substr(1,q.length-1):q.substr(1,q.length-1):q:q)}m[h+j]=o}return a};return h};var x=d("../helpers/Extend");b.api.compile=function(a){return function(){for(var b=null,c=null,d=null,e=0;e<arguments.length;e++)switch(typeof arguments[e]){case"function":c=arguments[e];break;case"string":b=arguments[e];break;case"object":d=arguments[e]}var f={combineSelectors:!0,minify:!1,keepCamelCase:!1,processor:a.defaultProcessor,api:a};d=x(f,d||{}),d.processor(a.getRules(),function(d,e){if(null!=b)try{A.writeFile(b,e,function(a){c(a,e)})}catch(d){c.apply({},arguments)}else c.apply({},arguments);a.flush()},d)}},b.api.compileFile=function(a){return a.compile};var y=function(a,b){a=String(a).replace(/[^0-9a-f]/gi,""),a.length<6&&(a=a[0]+a[0]+a[1]+a[1]+a[2]+a[2]),b=b||0;var c,d,e="#";for(d=0;3>d;d++)c=parseInt(a.substr(2*d,2),16),c=Math.round(Math.min(Math.max(0,c+c*b),255)).toString(16),e+=("00"+c).substr(c.length);return e};b.api.darken=function(){return function(a,b){return y(a,-(b/100))}},b.api.define=function(a){return function(b,c){return a.getStorage().__defined||(a.getStorage().__defined={}),a.getStorage().__defined[b]=c,a}},b.api.hook=function(a){return function(b,c){return a.addHook(b,c),a}};var y=function(a,b){a=String(a).replace(/[^0-9a-f]/gi,""),a.length<6&&(a=a[0]+a[0]+a[1]+a[1]+a[2]+a[2]),b=b||0;var c,d,e="#";for(d=0;3>d;d++)c=parseInt(a.substr(2*d,2),16),c=Math.round(Math.min(Math.max(0,c+c*b),255)).toString(16),e+=("00"+c).substr(c.length);return e};b.api.lighten=function(){return function(a,b){return y(a,b/100)}};var z={html:function(a){a.defaultProcessor=d(e+"/../processors/html/HTML.js")(),a.hook("add",function(b,c){return a.getRules(c||"mainstream").push(b),!0})},component:function(a){a.defaultProcessor=d(e+"/../processors/component/Component.js")(),a.hook("add",function(b){b instanceof Array||(b=[b]);for(var d=0;d<b.length,c=b[d];d++)a.getRules("mainstream").push(c);return!0})}};b.api.morph=function(a){return function(b){return z[b]&&(a.flush(),z[b](a)),a}},b.api.plugin=function(a){var b=function(b,c){return a.getPlugins()[b]=c,a};return b},b.api.raw=function(a){return function(b){var c={},d={},e="____raw_"+a.numOfAddedRules;return d[e]=b,c[e]=d,a.add(c),a}};{var A=d("fs");d("path")}b.api.rawImport=function(a){var b=function(b){var c=A.readFileSync(b,{encoding:"utf8"});a.raw(c)};return function(c){var d,e,f;if("string"==typeof c)b(c);else for(e=0,f=c.length;f>e;e++)d=c[e],b(d);return a}},b.api.register=function(a){return function(b,c){return a[b]=c,a}},b.api.storage=function(a){var b=a.getStorage(),c=function(d,e){if("undefined"!=typeof e)b[d]=e;else{if("object"!=typeof d){if(b[d])return b[d];throw new Error("There is no data in the storage associated with '"+d+"'")}for(var f in d)Object.prototype.hasOwnProperty.call(d,f)&&c(f,d[f])}return a};return c},b.helpers.Clone=function T(a){if(!a)return a;var b,c=[Number,String,Boolean];if(c.forEach(function(c){a instanceof c&&(b=c(a))}),"undefined"==typeof b)if("[object Array]"===Object.prototype.toString.call(a))b=[],a.forEach(function(a,c){b[c]=T(a)});else if("object"==typeof a)if(a.nodeType&&"function"==typeof a.cloneNode)var b=a.cloneNode(!0);else if(a.prototype)b=a;else if(a instanceof Date)b=new Date(a);else{b={};for(var d in a)b[d]=T(a[d])}else b=a;return b},b.helpers.ColorLuminance=function(a,b){a=String(a).replace(/[^0-9a-f]/gi,""),a.length<6&&(a=a[0]+a[0]+a[1]+a[1]+a[2]+a[2]),b=b||0;var c,d,e="#";for(d=0;3>d;d++)c=parseInt(a.substr(2*d,2),16),c=Math.round(Math.min(Math.max(0,c+c*b),255)).toString(16),e+=("00"+c).substr(c.length);return e},b.helpers.Extend=function(){for(var a=function(a,b){for(var c in b)hasOwnProperty.call(b,c)&&(a[c]=b[c]);return a},b=arguments[0],c=1;c<arguments.length;c++)b=a(b,arguments[c]);return b};var B=function(a){var b,c;return(c=a.match(/^\-(w|m|s|o)+\-/)||"-"===a.charAt(0))?null!==c&&c[0]?(b={prefix:c[0].replace(/-/g,"")},b.prop=a.replace(c[0],"")):(b={prefix:""},b.prop=a.substr(1,a.length)):b={prefix:!1,prop:a},b};b.helpers.Prefixes={addPrefixes:function(a,b){var c=a,d=B(a),e=b[a];d.prefix!==!1&&(delete b[c],b[d.prop]=e,(""===d.prefix||d.prefix.indexOf("w")>=0)&&(b["-webkit-"+d.prop]=e),(""===d.prefix||d.prefix.indexOf("m")>=0)&&(b["-moz-"+d.prop]=e),(""===d.prefix||d.prefix.indexOf("s")>=0)&&(b["-ms-"+d.prop]=e),(""===d.prefix||d.prefix.indexOf("o")>=0)&&(b["-o-"+d.prop]=e))},nonPrefixProp:function(a){var b=B(a);return b.prefix!==!1&&(b.prefix=""==b.prefix?"-":"-"+b.prefix+"-"),b}},b.helpers.RequireUncached=function(a){return delete d.cache[d.resolve(a)],d(a)},b.helpers.TransformUppercase=function(a){for(var b="",d=0;c=a.charAt(d);d++)b+=c===c.toUpperCase()&&c.toLowerCase()!==c.toUpperCase()?"-"+c.toLowerCase():c;return b};var C=function(a,b,f){var g="",h="",i=[],j=f.api;cssPreprocessor=d(e+"/../css/CSS.js")(),htmlPreprocessor=d(e+"/../html/HTML.js")();for(var k=function(a){for(var b=0;b<i.length,component=i[b];b++)"function"==typeof component&&(component=component()),j.add(component.css?component.css:{});cssPreprocessor(j.getRules(),function(b,c){g+=c,a(b)},f)},l=function(b){var c=0,d=null,e=function(){if(c>a.length-1)return b(d),void 0;var g=a[c];"function"==typeof g&&(g=g()),j.morph("html").add(g.html?g.html:{}),htmlPreprocessor(j.getRules(),function(a,b){h+=b,c+=1,d=a,e()},f)};e()},m=function(a){for(var b in a)if("_include"===b)if(a[b]instanceof Array)for(var d=0;d<a[b].length,c=a[b][d];d++)"function"==typeof c&&(c=c()),i.push(c),m(c);else"function"==typeof a[b]&&(a[b]=a[b]()),i.push(a[b]),m(a[b]);else"object"==typeof a[b]&&m(a[b])},n=0;n<a.length,c=a[n];n++)"function"==typeof c&&(c=c()),i.push(c),m(c);j.flush(),k(function(a){j.morph("html"),l(function(c){b(a||c?{error:{css:a,html:c}}:null,g,h)})})};b.processors.component.Component=function(){var a=function(a,b,c){C(a.mainstream,b,c)};return a.type="component",a};var D="\n",E={combineSelectors:!0,minify:!1,keepCamelCase:!1},F=d("../../helpers/TransformUppercase"),G=function(a,b,c){var d="";c=c||[""," "];for(var e in a)if(0===e.indexOf("____raw"))d+=a[e][e]+D;else{var f=c[0]+e.replace(/~~(.+)~~/,"")+" {"+D,g="";for(var h in a[e]){var i=a[e][h];""===i&&(i='""'),h=h.replace(/^%(.*)+?%/,"").replace(/~~(.+)~~/,""),g+=b&&b.keepCamelCase===!0?c[1]+h+": "+i+";"+D:c[1]+F(h)+": "+i+";"+D}""!=g&&(f+=g,f+=c[0]+"}"+D,d+=f)}return d},H=function(a,b){var c=[],d={},b=[].concat(b||[]);b.splice(0,0,""),b=b.join("|");for(var e in a){var f=a[e];for(var g in f)c.push({selector:e,prop:g,value:f[g],combine:b.indexOf("|"+g)<0})}for(var h=0;h<c.length;h++)if(c[h].combine===!0&&c[h].selector!==!1)for(var i=h+1;i<c.length;i++)c[h].prop===c[i].prop&&c[h].value===c[i].value&&(c[h].selector+=", "+c[i].selector,c[i].selector=!1);for(var h=0;h<c.length;h++)c[h].selector!==!1&&(d[c[h].selector]||(d[c[h].selector]={}),d[c[h].selector][c[h].prop]=c[h].value);return d},I=function(a){return a=a.replace(/\/\*(?:(?!\*\/)[\s\S])*\*\/|[\r\n\t]+/g,""),a=a.replace(/ {2,}/g," "),a=a.replace(/ ([{:}]) /g,"$1"),a=a.replace(/([;,]) /g,"$1"),a=a.replace(/ !/g,"!")},J=function(a,b){if(b&&b.api&&b.api.getStorage().__defined){var c=b.api.getStorage().__defined;for(var d in c){var e=new RegExp("<%( )?"+d+"( )?%>","g");a="function"!=typeof c[d]?a.replace(e,c[d]):a.replace(e,c[d]())}}return a};b.processors.css.CSS=function(){var a=function(a,b,c){c=c||E;var d="";for(var e in a){var f=a[e];f=c.combineSelectors?H(f,c.preventCombining):f,d+="mainstream"===e?G(f,c):e+" {"+D+G(f,c,[" "," "])+"}"+D}return d=J(d,c),c.minify?(d=I(d),b&&b(null,d)):b&&b(null,d),d};return a.type="css",a},b.processors.css.plugins.charset=function(){return function(a,b){"string"==typeof b?a.raw('@charset: "'+b+'";'):"object"==typeof b&&(b=b.charset.replace(/:/g,"").replace(/'/g,"").replace(/"/g,"").replace(/ /g,""),a.raw('@charset: "'+b+'";'))}},b.processors.css.plugins.document=function(){return function(a,b){if("object"==typeof b){var c="";if(c+="@"+b.vendor+"document",c+=" "+b.document,b.rules&&b.rules.length)for(var d=0;rule=b.rules[d];d++)a.handlecssrule(rule,c);else"undefined"!=typeof b.styles&&a.add(b.styles,c)}}},b.processors.css.plugins.keyframes=function(){return function(a,b){d(e+"/../CSS.js")(),d(e+"/../../../helpers/Prefixes");if("object"==typeof b){var c;if("undefined"!=typeof b.frames)c=b.frames;else if("undefined"!=typeof b.keyframes){c={};for(var f=0;rule=b.keyframes[f];f++)if("keyframe"===rule.type)for(var g=c[rule.values]={},h=0;declaration=rule.declarations[h];h++)"declaration"===declaration.type&&(g[declaration.property]=declaration.value)}var i=d(e+"/../../../../")();i.add(c).compile(function(c,d){var e="@keyframes "+b.name+" {\n";e+=d,e+="}",e=e+"\n"+e.replace("@keyframes","@-webkit-keyframes"),a.raw(e)},{combineSelectors:!1})}}},b.processors.css.plugins.media=function(){return function(a,b){var c=d(e+"/../CSS.js")();if("object"==typeof b){for(var f="@media "+b.media+" {\n",g={},h=0;rule=b.rules[h];h++){var i=g[rule.selectors.toString()]={};if("rule"===rule.type)for(var j=0;declaration=rule.declarations[j];j++)"declaration"===declaration.type&&(i[declaration.property]=declaration.value)}f+=c({mainstream:g}),f+="}",a.raw(f)}}},b.processors.css.plugins.namespace=function(){return function(a,b){"string"==typeof b?a.raw('@namespace: "'+b+'";'):"object"==typeof b&&(b=b.namespace.replace(/: /g,"").replace(/'/g,"").replace(/"/g,"").replace(/ /g,"").replace(/:h/g,"h"),a.raw('@namespace: "'+b+'";'))}},b.processors.css.plugins.page=function(){return function(a,b){if("object"==typeof b){var c="";c+=b.selectors.length>0?"@page "+b.selectors.join(", ")+" {\n":"@page {\n";for(var d=0;declaration=b.declarations[d];d++)"declaration"==declaration.type&&(c+=" "+declaration.property+": "+declaration.value+";\n");c+="}",a.raw(c)}}},b.processors.css.plugins.supports=function(){return function(a,b){var c=d(e+"/../CSS.js")();if("object"==typeof b){for(var f="@supports "+b.supports+" {\n",g={},h=0;rule=b.rules[h];h++){var i=g[rule.selectors.toString()]={};if("rule"===rule.type)for(var j=0;declaration=rule.declarations[j];j++)"declaration"===declaration.type&&(i[declaration.property]=declaration.value)}f+=c({mainstream:g}),f+="}",a.raw(f)}}};var K=null,D="\n",E={},L=d("js-beautify").html,M=d("../../helpers/TransformUppercase"),N={},O=function(a){var b="";for(var c in K)if(c==a)for(var d=K[c].length,e=0;d>e;e++)b+=Q("",K[c][e]);return b},P=function(a,b){return b&&b.keepCamelCase===!0?a:M(a,b)},Q=function(a,b){var c="",e="",f="",g=d("./helpers/PropAnalyzer")(a);if(a=g.tag,""!=g.attrs&&(e+=" "+g.attrs),"string"==typeof b)return R(a,e,b);var h=function(a){""!=f&&(f+=D),f+=a};for(var i in b){var j=b[i];switch(i){case"_attrs":for(var k in j)e+="function"==typeof j[k]?" "+P(k,N)+'="'+j[k]()+'"':" "+P(k,N)+'="'+j[k]+'"';break;case"_":h(j);break;case"_tpl":if("string"==typeof j)h(O(j));else if(j instanceof Array){for(var l="",m=0;tpl=j[m];m++)l+=O(tpl),m<j.length-1&&(l+=D);h(l)}break;case"_include":var l="",n=function(a){"function"==typeof a&&(a=a()),a.css&&a.html&&(a=a.html),l+=Q("",a)};if(j instanceof Array)for(var m=0;m<j.length,o=j[m];m++)n(o);else"object"==typeof j&&n(j);h(l);break;default:switch(typeof j){case"string":h(Q(i,j));break;case"object":if(j.length&&j.length>0){for(var l="",m=0;v=j[m];m++)l+=Q("","function"==typeof v?v():v),m<j.length-1&&(l+=D);h(Q(i,l))}else h(Q(i,j));break;case"function":h(Q(i,j()))}}}return c+=""!=a?R(a,e,f):f},R=function(a,b,c){var d="";return""==a&&""==b&&""!=c?c:(a=""==a?"div":a,d+=""!==c?"<"+P(a,N)+b+">"+D+c+D+"</"+P(a,N)+">":"<"+P(a,N)+b+"/>")},S=function(a){return a=d("./helpers/TemplateEngine")(a.replace(/[\r\t\n]/g,""),N),N.minify?a:L(a,{indent_size:N.indentSize||4})};return b.processors.html.HTML=function(){var a=function(a,b,c){K=a,b=b||function(){},c=N=c||E;var d=S(O("mainstream"));return b(null,d),d};return a.type="html",a},b.processors.html.helpers.PropAnalyzer=function(a){var b={tag:"",attrs:""},d=(a.length,""),e=!1,f=[],g="",h=!1,i="",j=!1;if(/(#|\.|\[|\])/gi.test(a)===!1)return{tag:a,attrs:""};for(var k=0;k<a.length,c=a[k];k++)"["!==c||j?j?"]"!=c?i+=c:(j=!1,k-=1):"."!==c||e?e?"."!=c&&"#"!=c&&"["!=c&&"]"!=c?d+=c:(f.push(d),e=!1,d="",k-=1):"#"!==c||h?h?"."!=c&&"#"!=c&&"["!=c&&"]"!=c?g+=c:(h=!1,k-=1):"."!=c&&"#"!=c&&"["!=c&&"]"!=c&&(b.tag+=c):h=!0:e=!0:j=!0;
-""!=d&&f.push(d);for(var l="",k=0;cls=f[k];k++)l+=""===l?cls:" "+cls;return b.attrs+=""!=l?'class="'+l+'"':"",""!=g&&(b.attrs+=(""!=b.attrs?" ":"")+'id="'+g+'"'),""===b.tag&&""!=b.attrs&&(b.tag="div"),""!=i&&(b.attrs+=(""!=b.attrs?" ":"")+i),b},b.processors.html.helpers.TemplateEngine=function(a,b){for(var c,d=/<%(.+?)%>/g,e=/(^( )?(var|if|for|else|switch|case|break|{|}|;))(.*)?/g,f="var r=[];\n",g=0,h=function(a,b){return f+=b?a.match(e)?a+"\n":"r.push("+a+");\n":""!=a?'r.push("'+a.replace(/"/g,'\\"')+'");\n':"",h};match=d.exec(a);)h(a.slice(g,match.index))(match[1],!0),g=match.index+match[0].length;h(a.substr(g,a.length-g)),f=(f+'return r.join("");').replace(/[\r\t\n]/g,"");try{c=new Function(f).apply(b)}catch(i){console.error("'"+i.message+"'"," in \n\nCode:\n",f,"\n")}return c},w()}(window);
+var Absurd=function(){var b={api:{},helpers:{},plugins:{},processors:{css:{plugins:{}},html:{plugins:{},helpers:{}},component:{plugins:{}}}},d=function(a){return a.indexOf("css/CSS.js")>0||"/../CSS.js"==a?b.processors.css.CSS:a.indexOf("html/HTML.js")>0?b.processors.html.HTML:a.indexOf("component/Component.js")>0?b.processors.component.Component:"js-beautify"==a?{html:function(a){return a}}:"./helpers/PropAnalyzer"==a?b.processors.html.helpers.PropAnalyzer:"../../helpers/TransformUppercase"==a?b.helpers.TransformUppercase:"./helpers/TemplateEngine"==a?b.processors.html.helpers.TemplateEngine:"../helpers/Extend"==a?b.helpers.Extend:"../helpers/Clone"==a?b.helpers.Clone:"../helpers/Prefixes"==a||"/../../../helpers/Prefixes"==a?b.helpers.Prefixes:a==e+"/../../../../"?Absurd:function(){}},e="",f=function(a,b){!function c(){a.length>0&&a.shift().apply(b||{},[c].concat(Array.prototype.slice.call(arguments,0)))}()},g=function(a){var b={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],area:[1,"<map>","</map>"],param:[1,"<object>","</object>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],body:[0,"",""],_default:[1,"<div>","</div>"]};b.optgroup=b.option,b.tbody=b.tfoot=b.colgroup=b.caption=b.thead,b.th=b.td;var c=/<\s*\w.*?>/g.exec(a),d=document.createElement("div");if(null!=c){var e=c[0].replace(/</g,"").replace(/>/g,"").split(" ")[0];if("body"===e.toLowerCase()){var f=(document.implementation.createDocument("http://www.w3.org/1999/xhtml","html",null),document.createElement("body"));d.innerHTML=a.replace(/<body/g,"<div").replace(/<\/body>/g,"</div>");var g=d.firstChild.attributes;f.innerHTML=a;for(var h=0;h<g.length;h++)f.setAttribute(g[h].name,g[h].value);return f}var d,i=b[e]||b._default;a=i[1]+a+i[2],d.innerHTML=a;for(var j=i[0]+1;j--;)d=d.lastChild}else d.innerHTML=a,d=d.lastChild;return d},h=function(a,b,c){return a.addEventListener?(a.addEventListener(b,c,!1),!0):a.attachEvent?a.attachEvent("on"+b,c):void 0},i=function(a){for(var b,c=a.childNodes,d=c.length,e=0,f=/^\s*$/;d>e;e++)b=c[e],3==b.nodeType&&f.test(b.nodeValue)&&(a.removeChild(b),e--,d--);return a},j=function(b,c,d){for(var e=document.createElement(b),f=0;f<c.length,a=c[f];f++)e.setAttribute(a.name,a.value);return e.innerHTML=d,e},k=function(a,b){return b=b===!1?document:b||this.el||document,b.querySelector(a)},l=function(a,b){return b=b===!1?document:b||this.el||document,b.querySelectorAll(a)},m=function(a,b){return b=b||this.el,b&&b.currentStyle?b.currentStyle[a]:window.getComputedStyle?document.defaultView.getComputedStyle(b,null).getPropertyValue(a):null},n=function(a,b){if(b=b||this.el,b.classList)b.classList.add(a);else{var c=b.className;c.indexOf(a)<0&&(""==c?b.className=a:b.className+=" "+a)}return this},q=function(a,b){if(b=b||this.el,b.classList)b.classList.remove(a);else{for(var c=b.className.split(" "),d=[],e=0;e<c.length;e++)c[e]!=a&&d.push(c[e]);b.className=d.join(" ")}return this},r=function(a,b,c){c=c||this.el;for(var d=c.className.split(" "),e=!1,f=0;f<d.length;f++)d[f]==a&&(e=!0,d[f]=b);return e?(c.className=d.join(" "),this):n(b,c)},s=function(a,b){if(b=b||this.el,b.classList)b.classList.toggle(a);else{for(var c=b.className.split(" "),d=-1,e=c.length;e--;)c[e]===a&&(d=e);d>=0?c.splice(d,1):c.push(a),b.className=c.join(" ")}return this},t=function(a,c,d,e){var o=b.helpers.Extend({__name:a},e),p=b.helpers.Extend,t=[];o.listeners=t,o.on=function(a,b,c){return t[a]||(t[a]=[]),t[a].push({callback:b,scope:c}),this},o.off=function(a,b){return t[a]?(b||(t[a]=[]),this):this},o.dispatch=function(a,b,c){if(!b||"object"!=typeof b||b instanceof Array||(b.target=this),t[a])for(var e=0;e<t[a].length;e++){var f=t[a][e].callback;f.apply(c||t[a][e].scope||{},[b])}return this[a]&&"function"==typeof this[a]&&this[a](b),d&&d.dispatch(a,b),this};var u={};o.set=function(a,b){return u[a]=b,this},o.get=function(a){return u[a]};var v=!1;o.__handleCSS=function(b){return this.css?c.flush().add(this.css).compile(function(c,d){if(v)v.raw!==d&&(v.raw=d,v.element.innerHTML=d);else{var e=j("style",[{name:"id",value:a+"-css"},{name:"type",value:"text/css"}],d);(k("head")||k("body")).appendChild(e),v={raw:d,element:e}}b()}):b(),this},o.applyCSS=function(a,b,c){if(this.html&&"string"==typeof this.html&&!b){var d={};d[this.html]=a,a=d}return this.css=a,c||this.populate(),this};var w=!1;o.__mergeDOMElements=function(a,b){if(i(a),i(b),"undefined"!=typeof a&&"undefined"!=typeof b&&!a.isEqualNode(b)){if(a.nodeName!==b.nodeName)return a.parentNode&&a.parentNode.replaceChild(b,a),void 0;if(a.nodeValue!==b.nodeValue&&(a.nodeValue=b.nodeValue),a.attributes){for(var c,d,e=a.attributes,f=b.attributes,g={},h=0;h<e.length,c=e[h];h++){for(var j=0;j<f.length,d=f[j];j++)c.name===d.name&&(a.setAttribute(c.name,d.value),g[c.name]=!0);g[c.name]||a.removeAttribute(c.name)}for(var h=0;h<f.length,d=f[h];h++)g[d.name]||a.setAttribute(d.name,d.value)}var k=[];if(a.childNodes.length>=b.childNodes.length)for(var h=0;h<a.childNodes.length;h++)b.childNodes[h]||b.appendChild(document.createTextNode("")),k.push([a.childNodes[h],b.childNodes[h]]);else for(var h=0;h<b.childNodes.length;h++)a.appendChild(document.createTextNode("")),k.push([a.childNodes[h],b.childNodes[h]]);for(var h=0;h<k.length;h++)o.__mergeDOMElements(k[h][0],k[h][1])}},o.__handleHTML=function(a){var b=this,d=function(){c.flush().morph("html").add(w).compile(function(c,d){b.el?o.__mergeDOMElements(b.el,g(d)):b.el=g(d),a()},b)};if(this.html)if("string"==typeof this.html){if(!this.el){var e=k(this.html);e&&(this.el=e,w={"":this.el.outerHTML.replace(/&lt;/g,"<").replace(/&gt;/g,">")})}d()}else"object"==typeof this.html?(w=p({},this.html),d()):a();else a();return this},o.applyHTML=function(a,b){return this.html=a,b||this.populate(),this};var x=!1;o.__append=function(a){return!x&&this.el&&this.get("parent")&&(x=!0,this.get("parent").appendChild(this.el)),a(),this};var y={events:{}};o.__handleEvents=function(a){if(this.el){var b=this,c=function(a){var c=a.getAttribute("data-absurd-event");if(c=c.split(":"),c.length>=2){var d=c[0],e=c[1];c.splice(0,2);var f=c;(!y.events[d]||y.events[d].indexOf(a)<0)&&(y.events[d]||(y.events[d]=[]),y.events[d].push(a),h(a,d,function(a){if("function"==typeof b[e]){var c=b[e];c.apply(b,[a].concat(f))}}))}};this.el.hasAttribute&&this.el.hasAttribute("data-absurd-event")&&c(this.el);for(var d=this.el.querySelectorAll?this.el.querySelectorAll("[data-absurd-event]"):[],e=0;e<d.length;e++)c(d[e])}return a(),this},o.__getAnimAndTransEndEventName=function(a){if(a){var b,c={animation:["animationend","transitionend"],OAnimation:["oAnimationEnd","oTransitionEnd"],MozAnimation:["animationend","transitionend"],WebkitAnimation:["webkitAnimationEnd","webkitTransitionEnd"]};for(b in c)if(void 0!==a.style[b])return c[b]}},o.onAnimationEnd=function(a,b){1==arguments.length&&(b=a,a=this.el);var c=this,d=o.__getAnimAndTransEndEventName(a);return d?(this.addEventListener(a,d[0],function(a){b.apply(c,[a])}),void 0):(b.apply(this,[{error:"Animations not supported."}]),void 0)},o.onTransitionEnd=function(a,b){1==arguments.length&&(b=a,a=this.el);var c=this,d=o.__getAnimAndTransEndEventName(a);return d?(this.addEventListener(a,d[1],function(a){b.apply(c,[a])}),void 0):(b.apply(this,[{error:"Animations not supported."}]),void 0)};var z={funcs:{},index:0};o.__handleAsyncFunctions=function(a){if(this.el){var b=[];if(this.el.hasAttribute&&this.el.hasAttribute("data-absurd-async"))b.push(this.el);else for(var c=this.el.querySelectorAll?this.el.querySelectorAll("[data-absurd-async]"):[],d=0;d<c.length;d++)b.push(c[d]);if(0===b.length)a();else{var e=this;!function f(){if(0===b.length)a();else{var c=b.shift(),d=c.getAttribute("data-absurd-async"),h=function(a){"string"==typeof a?c.parentNode.replaceChild(g(a),c):c.parentNode.replaceChild(a,c),f()};"function"==typeof e[z.funcs[d].name]?e[z.funcs[d].name].apply(e,[h].concat(z.funcs[d].args)):"function"==typeof z.funcs[d].func&&z.funcs[d].func.apply(e,[h].concat(z.funcs[d].args))}}()}}else a();return this},o.async=function(){var a=Array.prototype.slice.call(arguments,0),b=a.shift(),c="_"+z.index++;return z.funcs[c]={args:a,name:b},'<script data-absurd-async="'+c+'"></script>'},o.child=function(){var a=Array.prototype.slice.call(arguments,0),b=this.get("children"),c=b&&b[a.shift()],d="_"+z.index++;return z.funcs[d]={args:a,func:function(a){c.populate({callback:function(b){a(b.html.element)}})}},'<script data-absurd-async="'+d+'"></script>'},o.wire=function(a){return c.components.events.on(a,this[a]||function(){},this),this};var A=!1;return o.populate=function(a){return A?void 0:(A=!0,f([o.__handleCSS,o.__handleHTML,o.__append,o.__handleEvents,o.__handleAsyncFunctions,function(){A=!1,z={funcs:{},index:0};var b={css:v,html:{element:this.el}};this.dispatch("populated",b),a&&"function"==typeof a.callback&&a.callback(b)}],this),this)},o.str2DOMElement=g,o.addEventListener=h,o.queue=f,o.qs=k,o.qsa=l,o.getStyle=m,o.addClass=n,o.removeClass=q,o.replaceClass=r,o.toggleClass=s,o.compileHTML=function(a,b,d){c.flush().morph("html").add(a).compile(b,d)},o.compileCSS=function(a,b,d){c.flush().add(a).compile(b,d)},o.delay=function(a,b,c){var d=this;setTimeout(function(){b.apply(d,c)},a)},o},u=function(a){a.di.register("is",{appended:function(a){return"undefined"==typeof a&&(a=this.host.html),k(a)?!0:!1}}),a.di.register("router",{routes:[],mode:null,root:"/",getFragment:function(){var a="";if("history"===this.mode){if(!location)return"";a=this.clearSlashes(decodeURI(location.pathname+location.search)),a=a.replace(/\?(.*)$/,""),a="/"!=this.root?a.replace(this.root,""):a}else{if(!window)return"";var b=window.location.href.match(/#(.*)$/);a=b?b[1]:""}return this.clearSlashes(a)},clearSlashes:function(a){return a.toString().replace(/\/$/,"").replace(/^\//,"")},add:function(a,b){return"function"==typeof a&&(b=a,a=""),this.routes.push({re:a,handler:b}),this},remove:function(a){for(var b,c=0;c<this.routes.length,b=this.routes[c];c++)if(b.handler===a||b.re===a)return this.routes.splice(c,1),this;return this},flush:function(){return this.routes=[],this.mode=null,this.root="/",this},config:function(a){return this.mode=a&&a.mode&&"history"==a.mode&&history.pushState?"history":"hash",this.root=a&&a.root?"/"+this.clearSlashes(a.root)+"/":"/",this},listen:function(){var a=this,b=a.getFragment(),c=function(){b!==a.getFragment()&&(b=a.getFragment(),a.check(b))};return clearInterval(this.interval),this.interval=setInterval(c,50),this},check:function(a){for(var b=a||this.getFragment(),c=0;c<this.routes.length;c++){var d=b.match(this.routes[c].re);if(d)return d.shift(),this.routes[c].handler.apply(this.host||{},d),this}return this},navigate:function(a){return a=a?a:"","history"===this.mode?history.pushState(null,null,this.root+this.clearSlashes(a)):(window.location.href.match(/#(.*)$/),window.location.href=window.location.href.replace(/#(.*)$/,"")+"#"+a),this}}),a.di.register("ajax",{request:function(a){"string"==typeof a&&(a={url:a}),a.url=a.url||"",a.method=a.method||"get",a.data=a.data||{};var b=function(a,b){var c,d=[];for(var e in a)d.push(e+"="+encodeURIComponent(a[e]));return c=d.join("&"),""!=c?b?b.indexOf("?")<0?"?"+c:"&"+c:c:""},c={host:this.host||{},process:function(a){var c=this;return this.xhr=null,window.ActiveXObject?this.xhr=new ActiveXObject("Microsoft.XMLHTTP"):window.XMLHttpRequest&&(this.xhr=new XMLHttpRequest),this.xhr&&(this.xhr.onreadystatechange=function(){if(4==c.xhr.readyState&&200==c.xhr.status){var b=c.xhr.responseText;a.json===!0&&"undefined"!=typeof JSON&&(b=JSON.parse(b)),c.doneCallback&&c.doneCallback.apply(c.host,[b,c.xhr])}else 4==c.xhr.readyState&&c.failCallback&&c.failCallback.apply(c.host,[c.xhr]);c.alwaysCallback&&c.alwaysCallback.apply(c.host,[c.xhr])},"get"==a.method?this.xhr.open("GET",a.url+b(a.data,a.url),!0):(this.xhr.open(a.method,a.url,!0),this.setHeaders({"X-Requested-With":"XMLHttpRequest","Content-type":"application/x-www-form-urlencoded"})),a.headers&&"object"==typeof a.headers&&this.setHeaders(a.headers),setTimeout(function(){"get"==a.method?c.xhr.send():c.xhr.send(b(a.data))},20)),this},done:function(a){return this.doneCallback=a,this},fail:function(a){return this.failCallback=a,this},always:function(a){return this.alwaysCallback=a,this},setHeaders:function(a){for(var b in a)this.xhr&&this.xhr.setRequestHeader(b,a[b])}};return c.process(a)}});var b=function(a,c){var d=b.prototype.host,e={el:null};switch(typeof a){case"undefined":e.el=d.el;break;case"string":c=c&&"string"==typeof c?k.apply(d,[c]):c,e.el=k(a,c||d.el||document);break;case"object":if("undefined"==typeof a.nodeName){var f=function(a,b){b=b||this;for(var c in b)"undefined"!=typeof b[c].el?b[c]=b[c].val(a):"object"==typeof b[c]&&(b[c]=f(a,b[c]));return delete b.val,b},g={val:f};for(var h in a)g[h]=b.apply(this,[a[h]]);return g}e.el=a}return e.val=function(a){if(!this.el)return null;var b=!!a,d=function(a){return b?(this.el.value=a,e):this.el.value};switch(this.el.nodeName.toLowerCase()){case"input":var f=this.el.getAttribute("type");if("radio"!=f&&"checkbox"!=f)return d.apply(this,[a]);for(var g=l('[name="'+this.el.getAttribute("name")+'"]',c),h=[],i=0;i<g.length;i++)b&&g[i].checked&&g[i].value!==a?g[i].removeAttribute("checked"):b&&g[i].value===a?(g[i].setAttribute("checked","checked"),g[i].checked="checked"):g[i].checked&&h.push(g[i].value);if(!b)return"radio"==f?h[0]:h;break;case"textarea":return d.apply(this,[a]);case"select":if(!b)return this.el.value;for(var j=l("option",this.el),i=0;i<j.length;i++)j[i].getAttribute("value")===a?this.el.selectedIndex=i:j[i].removeAttribute("selected");break;default:if(!b)return"undefined"!=typeof this.el.textContent?this.el.textContent:"undefined"!=typeof this.el.innerText?typeof this.el.innerText:this.el.innerHTML;this.el.innerHTML=a}return b?e:null},e.dom=function(a,c){return b(a,c||e.el)},e};a.di.register("dom",b)},w=function(){return function(a){var d=function(a,b){for(var c in b)hasOwnProperty.call(b,c)&&(a[c]=b[c]);return a},e={defaultProcessor:b.processors.css.CSS()},f={},h={},i={},j={};e.getRules=function(a){return"undefined"==typeof a?f:("undefined"==typeof f[a]&&(f[a]=[]),f[a])},e.getPlugins=function(){return i},e.getStorage=function(){return h},e.flush=function(){return f={},h=[],j={},e.defaultProcessor=b.processors.css.CSS(),e},e.import=function(){return e.callHooks("import",arguments)?e:e},e.addHook=function(a,b){j[a]||(j[a]=[]);for(var d=!1,e=0;c=j[a][e];e++)c===b&&(d=!0);d===!1?j[a].push(b):null},e.callHooks=function(a,b){if(j[a])for(var d=0;c=j[a][d];d++)if(c.apply(e,b)===!0)return!0;return!1},e.numOfAddedRules=0,e.components=function(a){var c=b.helpers.Extend,d=b.helpers.Clone,e={},f=[],g=c({},t()),h={};return function(a){window&&(window.addEventListener?window.addEventListener("load",a):window.attachEvent&&window.attachEvent("onload",a))}(function(){h.broadcast("ready")}),h={events:g,register:function(b,h){return e[b]=function(){var e=c({},t(b,a,g,d(h)));return a.di.resolveObject(e),f.push(e),"function"==typeof e.constructor&&e.constructor.apply(e,Array.prototype.slice.call(arguments,0)),e}},get:function(a){if(e[a])return e[a];throw new Error("There is no component with name '"+a+"'.")},remove:function(a){return e[a]?(delete e[a],!0):!1},list:function(){var a=[];for(var b in e)a.push(b);return a},flush:function(){return e={},f=[],this},broadcast:function(a,b){for(var c=0;c<f.length,instance=f[c];c++)"function"==typeof instance[a]&&instance[a](b);return this}}}(e),e.component=function(a){return function(b,c){return"undefined"==typeof c?a.components.get(b):a.components.register(b,c)}}(e),e.di=b.DI(e),u(e),e.compile=function(a,b){if(e.callHooks("compile",arguments))return e;var c={combineSelectors:!0,minify:!1,processor:e.defaultProcessor,keepCamelCase:!1,api:e};b=d(c,b||{}),b.processor(e.getRules(),a||function(){},b),e.flush()};for(var k in b.api)"compile"!==k&&(e[k]=b.api[k](e),e[k]=function(a){return function(){var c=b.api[a](e);return e.callHooks(a,arguments)?e:c.apply(e,arguments)}}(k));for(var l in b.processors.css.plugins)e.plugin(l,b.processors.css.plugins[l]());return"function"==typeof a&&a(e),"undefined"!=typeof Organic&&Organic.init(e),e.utils={str2DOMElement:g},e}};b.DI=function(){var a={dependencies:{},register:function(a,b){return this.dependencies[a]=b,this},resolve:function(){var a,b,c,d=this,e=!1;"string"==typeof arguments[0]?(a=arguments[1],b=arguments[0].replace(/ /g,"").split(","),c=arguments[2]||{}):(a=arguments[0],b=a.toString().match(/^function\s*[^\(]*\(\s*([^\)]*)\)/m)[1].replace(/ /g,"").split(","),c=arguments[1]||{});for(var f=0;f<b.length;f++)"undefined"!=typeof this.dependencies[b[f]]&&(e=!0);return e?function(){for(var e=[],f=Array.prototype.slice.call(arguments,0),g=0;g<b.length;g++){var h=b[g];if("undefined"!=typeof d.dependencies[h]){var i=d.dependencies[h];"function"==typeof i?i.prototype.host=c:"object"==typeof i&&(i.host=c),e.push(i)}else e.push(f.shift())}return a.apply(c,e)}:a},resolveObject:function(a){if("object"==typeof a)for(var b in a)"function"==typeof a[b]?a[b]=this.resolve(a[b],a):a[b]instanceof Array&&2==a[b].length&&"string"==typeof a[b][0]&&"function"==typeof a[b][1]&&(a[b]=this.resolve(a[b][0],a[b][1],a));return this},flush:function(){return this.dependencies={},this}};return a},b.api.add=function(a){var b=(d("../helpers/Extend"),d("../helpers/Prefixes")),c=[],e={combineSelectors:!0,preventCombining:["@font-face"]},f=function(c,d,e,f,h){var i=b.nonPrefixProp(d),j=a.getPlugins()[i.prop];if("undefined"!=typeof j){var k=j(a,e,i.prefix);return k&&g(c,k,f,h),!0}return!1},g=function(a,d,h,i){if(h=h||"mainstream",null!==d&&"undefined"!=typeof d&&d!==!1)if(i||a||(a=""),/, ?/g.test(a)&&e.combineSelectors)for(var j=a.replace(/, /g,",").split(","),k=0;k<j.length,p=j[k];k++)g(p,d,h,i);else if(!f(null,a,d,h,i))if("undefined"==typeof d.length||"object"!=typeof d){var l={},m=a,n={},o={};for(var q in d){d[q]&&"undefined"!=typeof d[q].classify&&d[q].classify===!0&&(d[q]="undefined"!=typeof d[q].toJSON?d[q].toJSON():d[q].toString());var r=typeof d[q];"object"!==r&&"function"!==r&&d[q]!==!1&&d[q]!==!0?f(a,q,d[q],h,i)===!1&&(m=0===m.indexOf("^")?m.substr(1,m.length-1)+("undefined"!=typeof i?" "+i:""):"undefined"!=typeof i?i+" "+a:a,l[q]=d[q],b.addPrefixes(q,l)):"object"===r?n[q]=d[q]:"function"===r&&(o[q]=d[q])}c.push({selector:m,props:l,stylesheet:h});for(var q in n)if(":"===q.charAt(0))g(a+q,n[q],h,i);else if(/&/g.test(q))if(/, ?/g.test(q)&&e.combineSelectors)for(var j=q.replace(/, /g,",").split(","),k=0;k<j.length,p=j[k];k++)p.indexOf("&")>=0?g(p.replace(/&/g,a),n[q],h,i):g(p,n[q],h,"undefined"!=typeof i?i+" "+a:a);else g(q.replace(/&/g,a),n[q],h,i);else 0===q.indexOf("@media")||0===q.indexOf("@supports")?g(a,n[q],q,i):0===a.indexOf("@media")||0===q.indexOf("@supports")?g(q,n[q],a,i):0===a.indexOf("^")?g(a.substr(1,a.length-1)+("undefined"!=typeof i?" "+i:"")+" "+q,n[q],h):f(a,q,n[q],h,i)===!1&&g(q,n[q],h,(i?i+" ":"")+a);for(var q in o){var s={};s[q]=o[q](),g(a,s,h,i)}}else for(var k=0;k<d.length,q=d[k];k++)g(a,q,h,i)},h=function(b,d,f){try{c=[],a.numOfAddedRules+=1,"object"==typeof d&&"undefined"==typeof f&&(e={combineSelectors:"undefined"!=typeof d.combineSelectors?d.combineSelectors:e.combineSelectors,preventCombining:e.preventCombining.concat(d.preventCombining||[])},d=null),"undefined"!=typeof f&&(e={combineSelectors:f.combineSelectors||e.combineSelectors,preventCombining:e.preventCombining.concat(f.preventCombining||[])});var h,i=a.defaultProcessor.type;for(var j in b)g(j,b[j],d||"mainstream");for(var k=0;k<c.length;k++){var d=c[k].stylesheet,j=c[k].selector,l=c[k].props,m=a.getRules(d),n=e&&e.preventCombining?"|"+e.preventCombining.join("|"):"",h=n.indexOf("|"+j)>=0?"~~"+a.numOfAddedRules+"~~":"",o=m[h+j]||{};for(var p in l){var q=l[p];p=h+p,"object"!=typeof q&&(o[p]="css"==i?"+"===q.toString().charAt(0)?o&&o[p]?o[p]+", "+q.substr(1,q.length-1):q.substr(1,q.length-1):">"===q.toString().charAt(0)?o&&o[p]?o[p]+" "+q.substr(1,q.length-1):q.substr(1,q.length-1):q:q)}m[h+j]=o}return a}catch(r){throw new Error("Error adding: "+JSON.stringify(b))}};return h};var x=d("../helpers/Extend");b.api.compile=function(a){return function(){for(var b=null,c=null,d=null,e=0;e<arguments.length;e++)switch(typeof arguments[e]){case"function":c=arguments[e];break;case"string":b=arguments[e];break;case"object":d=arguments[e]}var f={combineSelectors:!0,minify:!1,keepCamelCase:!1,processor:a.defaultProcessor,api:a};d=x(f,d||{}),d.processor(a.getRules(),function(d,e){if(null!=b)try{A.writeFile(b,e,function(a){c(a,e)})}catch(d){c.apply({},arguments)}else c.apply({},arguments);a.flush()},d)}},b.api.compileFile=function(a){return a.compile};var y=function(a,b){a=String(a).replace(/[^0-9a-f]/gi,""),a.length<6&&(a=a[0]+a[0]+a[1]+a[1]+a[2]+a[2]),b=b||0;var c,d,e="#";for(d=0;3>d;d++)c=parseInt(a.substr(2*d,2),16),c=Math.round(Math.min(Math.max(0,c+c*b),255)).toString(16),e+=("00"+c).substr(c.length);return e};b.api.darken=function(){return function(a,b){return y(a,-(b/100))}},b.api.define=function(a){return function(b,c){return a.getStorage().__defined||(a.getStorage().__defined={}),a.getStorage().__defined[b]=c,a}},b.api.hook=function(a){return function(b,c){return a.addHook(b,c),a}};var y=function(a,b){a=String(a).replace(/[^0-9a-f]/gi,""),a.length<6&&(a=a[0]+a[0]+a[1]+a[1]+a[2]+a[2]),b=b||0;var c,d,e="#";for(d=0;3>d;d++)c=parseInt(a.substr(2*d,2),16),c=Math.round(Math.min(Math.max(0,c+c*b),255)).toString(16),e+=("00"+c).substr(c.length);return e};b.api.lighten=function(){return function(a,b){return y(a,b/100)}};var z={html:function(a){a.defaultProcessor=d(e+"/../processors/html/HTML.js")(),a.hook("add",function(b,c){return a.getRules(c||"mainstream").push(b),!0})},component:function(a){a.defaultProcessor=d(e+"/../processors/component/Component.js")(),a.hook("add",function(b){b instanceof Array||(b=[b]);for(var d=0;d<b.length,c=b[d];d++)a.getRules("mainstream").push(c);return!0})}};b.api.morph=function(a){return function(b){return z[b]&&(a.flush(),z[b](a)),a}},b.api.plugin=function(a){var b=function(b,c){return a.getPlugins()[b]=c,a};return b},b.api.raw=function(a){return function(b){var c={},d={},e="____raw_"+a.numOfAddedRules;return d[e]=b,c[e]=d,a.add(c),a}};{var A=d("fs");d("path")}b.api.rawImport=function(a){var b=function(b){var c=A.readFileSync(b,{encoding:"utf8"});a.raw(c)};return function(c){var d,e,f;if("string"==typeof c)b(c);else for(e=0,f=c.length;f>e;e++)d=c[e],b(d);return a}},b.api.register=function(a){return function(b,c){return a[b]=c,a}},b.api.storage=function(a){var b=a.getStorage(),c=function(d,e){if("undefined"!=typeof e)b[d]=e;else{if("object"!=typeof d){if(b[d])return b[d];throw new Error("There is no data in the storage associated with '"+d+"'")}for(var f in d)Object.prototype.hasOwnProperty.call(d,f)&&c(f,d[f])}return a};return c},b.helpers.Clone=function T(a){if(!a)return a;var b,c=[Number,String,Boolean];if(c.forEach(function(c){a instanceof c&&(b=c(a))}),"undefined"==typeof b)if("[object Array]"===Object.prototype.toString.call(a))b=[],a.forEach(function(a,c){b[c]=T(a)});else if("object"==typeof a)if(a.nodeType&&"function"==typeof a.cloneNode)var b=a.cloneNode(!0);else if(a.prototype)b=a;else if(a instanceof Date)b=new Date(a);else{b={};for(var d in a)b[d]=T(a[d])}else b=a;return b},b.helpers.ColorLuminance=function(a,b){a=String(a).replace(/[^0-9a-f]/gi,""),a.length<6&&(a=a[0]+a[0]+a[1]+a[1]+a[2]+a[2]),b=b||0;var c,d,e="#";for(d=0;3>d;d++)c=parseInt(a.substr(2*d,2),16),c=Math.round(Math.min(Math.max(0,c+c*b),255)).toString(16),e+=("00"+c).substr(c.length);return e},b.helpers.Extend=function(){for(var a=function(a,b){for(var c in b)hasOwnProperty.call(b,c)&&(a[c]=b[c]);return a},b=arguments[0],c=1;c<arguments.length;c++)b=a(b,arguments[c]);return b};var B=function(a){var b,c;return(c=a.match(/^\-(w|m|s|o)+\-/)||"-"===a.charAt(0))?null!==c&&c[0]?(b={prefix:c[0].replace(/-/g,"")},b.prop=a.replace(c[0],"")):(b={prefix:""},b.prop=a.substr(1,a.length)):b={prefix:!1,prop:a},b};b.helpers.Prefixes={addPrefixes:function(a,b){var c=a,d=B(a),e=b[a];d.prefix!==!1&&(delete b[c],b[d.prop]=e,(""===d.prefix||d.prefix.indexOf("w")>=0)&&(b["-webkit-"+d.prop]=e),(""===d.prefix||d.prefix.indexOf("m")>=0)&&(b["-moz-"+d.prop]=e),(""===d.prefix||d.prefix.indexOf("s")>=0)&&(b["-ms-"+d.prop]=e),(""===d.prefix||d.prefix.indexOf("o")>=0)&&(b["-o-"+d.prop]=e))},nonPrefixProp:function(a){var b=B(a);return b.prefix!==!1&&(b.prefix=""==b.prefix?"-":"-"+b.prefix+"-"),b}},b.helpers.RequireUncached=function(a){return delete d.cache[d.resolve(a)],d(a)},b.helpers.TransformUppercase=function(a){for(var b="",d=0;c=a.charAt(d);d++)b+=c===c.toUpperCase()&&c.toLowerCase()!==c.toUpperCase()?"-"+c.toLowerCase():c;return b};var C=function(a,b,f){var g="",h="",i=[],j=f.api;cssPreprocessor=d(e+"/../css/CSS.js")(),htmlPreprocessor=d(e+"/../html/HTML.js")();for(var k=function(a){for(var b=0;b<i.length,component=i[b];b++)"function"==typeof component&&(component=component()),j.add(component.css?component.css:{});cssPreprocessor(j.getRules(),function(b,c){g+=c,a(b)},f)},l=function(b){var c=0,d=null,e=function(){if(c>a.length-1)return b(d),void 0;var g=a[c];"function"==typeof g&&(g=g()),j.morph("html").add(g.html?g.html:{}),htmlPreprocessor(j.getRules(),function(a,b){h+=b,c+=1,d=a,e()},f)};e()},m=function(a){for(var b in a)if("_include"===b)if(a[b]instanceof Array)for(var d=0;d<a[b].length,c=a[b][d];d++)"function"==typeof c&&(c=c()),i.push(c),m(c);else"function"==typeof a[b]&&(a[b]=a[b]()),i.push(a[b]),m(a[b]);else"object"==typeof a[b]&&m(a[b])},n=0;n<a.length,c=a[n];n++)"function"==typeof c&&(c=c()),i.push(c),m(c);j.flush(),k(function(a){j.morph("html"),l(function(c){b(a||c?{error:{css:a,html:c}}:null,g,h)})})};b.processors.component.Component=function(){var a=function(a,b,c){C(a.mainstream,b,c)};return a.type="component",a};var D="\n",E={combineSelectors:!0,minify:!1,keepCamelCase:!1},F=d("../../helpers/TransformUppercase"),G=function(a,b,c){var d="";c=c||[""," "];for(var e in a)if(0===e.indexOf("____raw"))d+=a[e][e]+D;else{var f=c[0]+e.replace(/~~(.+)~~/,"")+" {"+D,g="";for(var h in a[e]){var i=a[e][h];""===i&&(i='""'),h=h.replace(/^%(.*)+?%/,"").replace(/~~(.+)~~/,""),g+=b&&b.keepCamelCase===!0?c[1]+h+": "+i+";"+D:c[1]+F(h)+": "+i+";"+D}""!=g&&(f+=g,f+=c[0]+"}"+D,d+=f)}return d},H=function(a,b){var c=[],d={},b=[].concat(b||[]);b.splice(0,0,""),b=b.join("|");for(var e in a){var f=a[e];for(var g in f)c.push({selector:e,prop:g,value:f[g],combine:b.indexOf("|"+g)<0})}for(var h=0;h<c.length;h++)if(c[h].combine===!0&&c[h].selector!==!1)for(var i=h+1;i<c.length;i++)c[h].prop===c[i].prop&&c[h].value===c[i].value&&(c[h].selector+=", "+c[i].selector,c[i].selector=!1);for(var h=0;h<c.length;h++)c[h].selector!==!1&&(d[c[h].selector]||(d[c[h].selector]={}),d[c[h].selector][c[h].prop]=c[h].value);return d},I=function(a){return a=a.replace(/\/\*(?:(?!\*\/)[\s\S])*\*\/|[\r\n\t]+/g,""),a=a.replace(/ {2,}/g," "),a=a.replace(/ ([{:}]) /g,"$1"),a=a.replace(/([;,]) /g,"$1"),a=a.replace(/ !/g,"!")},J=function(a,b){if(b&&b.api&&b.api.getStorage().__defined){var c=b.api.getStorage().__defined;for(var d in c){var e=new RegExp("<%( )?"+d+"( )?%>","g");a="function"!=typeof c[d]?a.replace(e,c[d]):a.replace(e,c[d]())}}return a};b.processors.css.CSS=function(){var a=function(a,b,c){c=c||E;var d="";for(var e in a){var f=a[e];f=c.combineSelectors?H(f,c.preventCombining):f,d+="mainstream"===e?G(f,c):e+" {"+D+G(f,c,[" "," "])+"}"+D}return d=J(d,c),c.minify?(d=I(d),b&&b(null,d)):b&&b(null,d),d};return a.type="css",a},b.processors.css.plugins.charset=function(){return function(a,b){"string"==typeof b?a.raw('@charset: "'+b+'";'):"object"==typeof b&&(b=b.charset.replace(/:/g,"").replace(/'/g,"").replace(/"/g,"").replace(/ /g,""),a.raw('@charset: "'+b+'";'))}},b.processors.css.plugins.document=function(){return function(a,b){if("object"==typeof b){var c="";if(c+="@"+b.vendor+"document",c+=" "+b.document,b.rules&&b.rules.length)for(var d=0;rule=b.rules[d];d++)a.handlecssrule(rule,c);else"undefined"!=typeof b.styles&&a.add(b.styles,c)}}},b.processors.css.plugins.keyframes=function(){return function(a,b){d(e+"/../CSS.js")(),d(e+"/../../../helpers/Prefixes");if("object"==typeof b){var c;if("undefined"!=typeof b.frames)c=b.frames;else if("undefined"!=typeof b.keyframes){c={};for(var f=0;rule=b.keyframes[f];f++)if("keyframe"===rule.type)for(var g=c[rule.values]={},h=0;declaration=rule.declarations[h];h++)"declaration"===declaration.type&&(g[declaration.property]=declaration.value)}var i=d(e+"/../../../../")();i.add(c).compile(function(c,d){var e="@keyframes "+b.name+" {\n";e+=d,e+="}",e=e+"\n"+e.replace("@keyframes","@-webkit-keyframes"),a.raw(e)},{combineSelectors:!1})}}},b.processors.css.plugins.media=function(){return function(a,b){var c=d(e+"/../CSS.js")();if("object"==typeof b){for(var f="@media "+b.media+" {\n",g={},h=0;rule=b.rules[h];h++){var i=g[rule.selectors.toString()]={};if("rule"===rule.type)for(var j=0;declaration=rule.declarations[j];j++)"declaration"===declaration.type&&(i[declaration.property]=declaration.value)}f+=c({mainstream:g}),f+="}",a.raw(f)}}},b.processors.css.plugins.namespace=function(){return function(a,b){"string"==typeof b?a.raw('@namespace: "'+b+'";'):"object"==typeof b&&(b=b.namespace.replace(/: /g,"").replace(/'/g,"").replace(/"/g,"").replace(/ /g,"").replace(/:h/g,"h"),a.raw('@namespace: "'+b+'";'))}},b.processors.css.plugins.page=function(){return function(a,b){if("object"==typeof b){var c="";c+=b.selectors.length>0?"@page "+b.selectors.join(", ")+" {\n":"@page {\n";for(var d=0;declaration=b.declarations[d];d++)"declaration"==declaration.type&&(c+=" "+declaration.property+": "+declaration.value+";\n");c+="}",a.raw(c)}}},b.processors.css.plugins.supports=function(){return function(a,b){var c=d(e+"/../CSS.js")();if("object"==typeof b){for(var f="@supports "+b.supports+" {\n",g={},h=0;rule=b.rules[h];h++){var i=g[rule.selectors.toString()]={};if("rule"===rule.type)for(var j=0;declaration=rule.declarations[j];j++)"declaration"===declaration.type&&(i[declaration.property]=declaration.value)}f+=c({mainstream:g}),f+="}",a.raw(f)}}};var K=null,D="\n",E={},L=d("js-beautify").html,M=d("../../helpers/TransformUppercase"),N={},O=function(a){var b="";for(var c in K)if(c==a)for(var d=K[c].length,e=0;d>e;e++)b+=Q("",K[c][e]);return b},P=function(a,b){return b&&b.keepCamelCase===!0?a:M(a,b)},Q=function(a,b){var c="",e="",f="",g=d("./helpers/PropAnalyzer")(a);if(a=g.tag,""!=g.attrs&&(e+=" "+g.attrs),"string"==typeof b)return R(a,e,b);var h=function(a){""!=f&&(f+=D),f+=a};for(var i in b){var j=b[i];switch(i){case"_attrs":for(var k in j)e+="function"==typeof j[k]?" "+P(k,N)+'="'+j[k]()+'"':" "+P(k,N)+'="'+j[k]+'"';break;case"_":h(j);break;case"_tpl":if("string"==typeof j)h(O(j));else if(j instanceof Array){for(var l="",m=0;tpl=j[m];m++)l+=O(tpl),m<j.length-1&&(l+=D);h(l)}break;case"_include":var l="",n=function(a){"function"==typeof a&&(a=a()),a.css&&a.html&&(a=a.html),l+=Q("",a)};if(j instanceof Array)for(var m=0;m<j.length,o=j[m];m++)n(o);else"object"==typeof j&&n(j);h(l);break;default:switch(typeof j){case"string":h(Q(i,j));break;case"object":if(j.length&&j.length>0){for(var l="",m=0;v=j[m];m++)l+=Q("","function"==typeof v?v():v),m<j.length-1&&(l+=D);h(Q(i,l))}else h(Q(i,j));break;case"function":h(Q(i,j()))}}}return c+=""!=a?R(a,e,f):f},R=function(a,b,c){var d="";return""==a&&""==b&&""!=c?c:(a=""==a?"div":a,d+=""!==c?"<"+P(a,N)+b+">"+D+c+D+"</"+P(a,N)+">":"<"+P(a,N)+b+"/>")},S=function(a){return a=d("./helpers/TemplateEngine")(a.replace(/[\r\t\n]/g,""),N),N.minify?a:L(a,{indent_size:N.indentSize||4})};return b.processors.html.HTML=function(){var a=function(a,b,c){K=a,b=b||function(){},c=N=c||E;var d=S(O("mainstream"));return b(null,d),d};return a.type="html",a},b.processors.html.helpers.PropAnalyzer=function(a){var b={tag:"",attrs:""},d=(a.length,""),e=!1,f=[],g="",h=!1,i="",j=!1;
+if(/(#|\.|\[|\])/gi.test(a)===!1)return{tag:a,attrs:""};for(var k=0;k<a.length,c=a[k];k++)"["!==c||j?j?"]"!=c?i+=c:(j=!1,k-=1):"."!==c||e?e?"."!=c&&"#"!=c&&"["!=c&&"]"!=c?d+=c:(f.push(d),e=!1,d="",k-=1):"#"!==c||h?h?"."!=c&&"#"!=c&&"["!=c&&"]"!=c?g+=c:(h=!1,k-=1):"."!=c&&"#"!=c&&"["!=c&&"]"!=c&&(b.tag+=c):h=!0:e=!0:j=!0;""!=d&&f.push(d);for(var l="",k=0;cls=f[k];k++)l+=""===l?cls:" "+cls;return b.attrs+=""!=l?'class="'+l+'"':"",""!=g&&(b.attrs+=(""!=b.attrs?" ":"")+'id="'+g+'"'),""===b.tag&&""!=b.attrs&&(b.tag="div"),""!=i&&(b.attrs+=(""!=b.attrs?" ":"")+i),b},b.processors.html.helpers.TemplateEngine=function(a,b){for(var c,d=/<%(.+?)%>/g,e=/(^( )?(var|if|for|else|switch|case|break|{|}|;))(.*)?/g,f="var r=[];\n",g=0,h=function(a,b){return f+=b?a.match(e)?a+"\n":"r.push("+a+");\n":""!=a?'r.push("'+a.replace(/"/g,'\\"')+'");\n':"",h};match=d.exec(a);)h(a.slice(g,match.index))(match[1],!0),g=match.index+match[0].length;h(a.substr(g,a.length-g)),f=(f+'return r.join("");').replace(/[\r\t\n]/g,"");try{c=new Function(f).apply(b)}catch(i){console.error("'"+i.message+"'"," in \n\nCode:\n",f,"\n")}return c},w()}(window);
View
2 client-side/build/absurd.organic.js
@@ -1,4 +1,4 @@
-/* version: 0.3.136, born: 3-2-2014 15:31 */
+/* version: 0.3.137, born: 3-2-2014 15:49 */
var Organic = (function(w){
var o = {
helpers: {},
View
22 client-side/tests/tests.from.node.js
@@ -2969,4 +2969,26 @@ describe("Should allow setting styles with same names", function() {
}, { minify: true });
});
+});
+describe("Should report errors properly", function() {
+
+ var api = require('../../index.js')();
+
+ it("should compile properly", function(done) {
+ try {
+ api.add({
+ body: {
+ width: undefined,
+ padding: '20px'
+ }
+ }).compile(function(err, css) {
+ console.log(css);
+ done();
+ }, { minify: false });
+ } catch(err) {
+ expect(err.toString()).toBe('Error: Error adding: {"body":{"padding":"20px"}}');
+ done();
+ }
+ });
+
});
View
108 lib/api/add.js
@@ -136,70 +136,76 @@ module.exports = function(API) {
var add = function(rules, stylesheet, opts) {
- toRegister = [];
- API.numOfAddedRules += 1;
-
- if(typeof stylesheet === 'object' && typeof opts === 'undefined') {
- options = {
- combineSelectors: typeof stylesheet.combineSelectors != 'undefined' ? stylesheet.combineSelectors : options.combineSelectors,
- preventCombining: options.preventCombining.concat(stylesheet.preventCombining || [])
- };
- stylesheet = null;
- }
- if(typeof opts != 'undefined') {
- options = {
- combineSelectors: opts.combineSelectors || options.combineSelectors,
- preventCombining: options.preventCombining.concat(opts.preventCombining || [])
- };
- }
+ try {
- var typeOfPreprocessor = API.defaultProcessor.type, uid;
+ toRegister = [];
+ API.numOfAddedRules += 1;
- for(var selector in rules) {
- addRule(selector, rules[selector], stylesheet || "mainstream");
- }
+ if(typeof stylesheet === 'object' && typeof opts === 'undefined') {
+ options = {
+ combineSelectors: typeof stylesheet.combineSelectors != 'undefined' ? stylesheet.combineSelectors : options.combineSelectors,
+ preventCombining: options.preventCombining.concat(stylesheet.preventCombining || [])
+ };
+ stylesheet = null;
+ }
+ if(typeof opts != 'undefined') {
+ options = {
+ combineSelectors: opts.combineSelectors || options.combineSelectors,
+ preventCombining: options.preventCombining.concat(opts.preventCombining || [])
+ };
+ }
- // looping through the rules for registering
- for(var i=0; i<toRegister.length; i++) {
- var stylesheet = toRegister[i].stylesheet,
- selector = toRegister[i].selector,
- props = toRegister[i].props,
- allRules = API.getRules(stylesheet);
- var pc = options && options.preventCombining ? '|' + options.preventCombining.join('|') : '';
- var uid = pc.indexOf('|' + selector) >= 0 ? '~~' + API.numOfAddedRules + '~~' : '';
- // overwrite already added value
- var current = allRules[uid + selector] || {};
- for(var propNew in props) {
- var value = props[propNew];
- propNew = uid + propNew;
- if(typeof value != 'object') {
- if(typeOfPreprocessor == "css") {
- // appending values
- if(value.toString().charAt(0) === "+") {
- if(current && current[propNew]) {
- current[propNew] = current[propNew] + ", " + value.substr(1, value.length-1);
- } else {
- current[propNew] = value.substr(1, value.length-1);
- }
- } else if(value.toString().charAt(0) === ">") {
- if(current && current[propNew]) {
- current[propNew] = current[propNew] + " " + value.substr(1, value.length-1);
+ var typeOfPreprocessor = API.defaultProcessor.type, uid;
+
+ for(var selector in rules) {
+ addRule(selector, rules[selector], stylesheet || "mainstream");
+ }
+
+ // looping through the rules for registering
+ for(var i=0; i<toRegister.length; i++) {
+ var stylesheet = toRegister[i].stylesheet,
+ selector = toRegister[i].selector,
+ props = toRegister[i].props,
+ allRules = API.getRules(stylesheet);
+ var pc = options && options.preventCombining ? '|' + options.preventCombining.join('|') : '';
+ var uid = pc.indexOf('|' + selector) >= 0 ? '~~' + API.numOfAddedRules + '~~' : '';
+ // overwrite already added value
+ var current = allRules[uid + selector] || {};
+ for(var propNew in props) {
+ var value = props[propNew];
+ propNew = uid + propNew;
+ if(typeof value != 'object') {
+ if(typeOfPreprocessor == "css") {
+ // appending values
+ if(value.toString().charAt(0) === "+") {
+ if(current && current[propNew]) {
+ current[propNew] = current[propNew] + ", " + value.substr(1, value.length-1);
+ } else {
+ current[propNew] = value.substr(1, value.length-1);
+ }
+ } else if(value.toString().charAt(0) === ">") {
+ if(current && current[propNew]) {
+ current[propNew] = current[propNew] + " " + value.substr(1, value.length-1);
+ } else {
+ current[propNew] = value.substr(1, value.length-1);
+ }
} else {
- current[propNew] = value.substr(1, value.length-1);
+ current[propNew] = value;
}
} else {
current[propNew] = value;
}
- } else {
- current[propNew] = value;
+
}
-
}
+ allRules[uid + selector] = current;
}
- allRules[uid + selector] = current;
- }
return API;
+
+ } catch(err) {
+ throw new Error("Error adding: " + JSON.stringify(rules));
+ }
}
return add;
}
View
2 package.json
@@ -1,6 +1,6 @@
{
"name": "absurd",
- "version": "0.3.136",
+ "version": "0.3.137",
"homepage": "http://absurdjs.com/",
"description": "CSS/HTML preprocessor. Check out krasimirtsonev.com/blog/article/AbsurdJS-fundamentals",
"main": "./index.js",
View
108 tasks/tmp/absurd.js
@@ -199,70 +199,76 @@ lib.api.add = function(API) {
var add = function(rules, stylesheet, opts) {
- toRegister = [];
- API.numOfAddedRules += 1;
-
- if(typeof stylesheet === 'object' && typeof opts === 'undefined') {
- options = {
- combineSelectors: typeof stylesheet.combineSelectors != 'undefined' ? stylesheet.combineSelectors : options.combineSelectors,
- preventCombining: options.preventCombining.concat(stylesheet.preventCombining || [])
- };
- stylesheet = null;
- }
- if(typeof opts != 'undefined') {
- options = {
- combineSelectors: opts.combineSelectors || options.combineSelectors,
- preventCombining: options.preventCombining.concat(opts.preventCombining || [])
- };
- }
+ try {
- var typeOfPreprocessor = API.defaultProcessor.type, uid;
+ toRegister = [];
+ API.numOfAddedRules += 1;
- for(var selector in rules) {
- addRule(selector, rules[selector], stylesheet || "mainstream");
- }
+ if(typeof stylesheet === 'object' && typeof opts === 'undefined') {
+ options = {
+ combineSelectors: typeof stylesheet.combineSelectors != 'undefined' ? stylesheet.combineSelectors : options.combineSelectors,
+ preventCombining: options.preventCombining.concat(stylesheet.preventCombining || [])
+ };
+ stylesheet = null;
+ }
+ if(typeof opts != 'undefined') {
+ options = {
+ combineSelectors: opts.combineSelectors || options.combineSelectors,
+ preventCombining: options.preventCombining.concat(opts.preventCombining || [])
+ };
+ }
- // looping through the rules for registering
- for(var i=0; i<toRegister.length; i++) {
- var stylesheet = toRegister[i].stylesheet,
- selector = toRegister[i].selector,
- props = toRegister[i].props,
- allRules = API.getRules(stylesheet);
- var pc = options && options.preventCombining ? '|' + options.preventCombining.join('|') : '';
- var uid = pc.indexOf('|' + selector) >= 0 ? '~~' + API.numOfAddedRules + '~~' : '';
- // overwrite already added value
- var current = allRules[uid + selector] || {};
- for(var propNew in props) {
- var value = props[propNew];
- propNew = uid + propNew;
- if(typeof value != 'object') {
- if(typeOfPreprocessor == "css") {
- // appending values
- if(value.toString().charAt(0) === "+") {
- if(current && current[propNew]) {
- current[propNew] = current[propNew] + ", " + value.substr(1, value.length-1);
- } else {
- current[propNew] = value.substr(1, value.length-1);
- }
- } else if(value.toString().charAt(0) === ">") {
- if(current && current[propNew]) {
- current[propNew] = current[propNew] + " " + value.substr(1, value.length-1);
+ var typeOfPreprocessor = API.defaultProcessor.type, uid;
+
+ for(var selector in rules) {
+ addRule(selector, rules[selector], stylesheet || "mainstream");
+ }
+
+ // looping through the rules for registering
+ for(var i=0; i<toRegister.length; i++) {
+ var stylesheet = toRegister[i].stylesheet,
+ selector = toRegister[i].selector,
+ props = toRegister[i].props,
+ allRules = API.getRules(stylesheet);
+ var pc = options && options.preventCombining ? '|' + options.preventCombining.join('|') : '';
+ var uid = pc.indexOf('|' + selector) >= 0 ? '~~' + API.numOfAddedRules + '~~' : '';
+ // overwrite already added value
+ var current = allRules[uid + selector] || {};
+ for(var propNew in props) {
+ var value = props[propNew];
+ propNew = uid + propNew;
+ if(typeof value != 'object') {
+ if(typeOfPreprocessor == "css") {
+ // appending values
+ if(value.toString().charAt(0) === "+") {
+ if(current && current[propNew]) {
+ current[propNew] = current[propNew] + ", " + value.substr(1, value.length-1);
+ } else {
+ current[propNew] = value.substr(1, value.length-1);
+ }
+ } else if(value.toString().charAt(0) === ">") {
+ if(current && current[propNew]) {
+ current[propNew] = current[propNew] + " " + value.substr(1, value.length-1);
+ } else {
+ current[propNew] = value.substr(1, value.length-1);
+ }
} else {
- current[propNew] = value.substr(1, value.length-1);
+ current[propNew] = value;
}
} else {
current[propNew] = value;
}
- } else {
- current[propNew] = value;
+
}
-
}
+ allRules[uid + selector] = current;
}
- allRules[uid + selector] = current;
- }
return API;
+
+ } catch(err) {
+ throw new Error("Error adding: " + JSON.stringify(rules));
+ }
}
return add;
}
View
22 tests/experimental/error.reporting.spec.js
@@ -0,0 +1,22 @@
+describe("Should report errors properly", function() {
+
+ var api = require('../../index.js')();
+
+ it("should compile properly", function(done) {
+ try {
+ api.add({
+ body: {
+ width: undefined,
+ padding: '20px'
+ }
+ }).compile(function(err, css) {
+ console.log(css);
+ done();
+ }, { minify: false });
+ } catch(err) {
+ expect(err.toString()).toBe('Error: Error adding: {"body":{"padding":"20px"}}');
+ done();
+ }
+ });
+
+});

0 comments on commit e51e72e

Please sign in to comment.