diff --git a/bower.json b/bower.json index 6213ad0..8f11bfc 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "jasmine-fixture", - "version": "1.1.0", + "version": "1.2.0", "main": "dist/jasmine-fixture.js", "ignore": [ "app", diff --git a/dist/jasmine-fixture.js b/dist/jasmine-fixture.js index 1236b68..1a6d539 100644 --- a/dist/jasmine-fixture.js +++ b/dist/jasmine-fixture.js @@ -1,4 +1,4 @@ -/* jasmine-fixture - 1.1.0 +/* jasmine-fixture - 1.2.0 * Makes injecting HTML snippets into the DOM easy & clean! * https://github.com/searls/jasmine-fixture */ @@ -7,9 +7,10 @@ __slice = [].slice; (function($) { - var jasmineFixture, originalAffix, originalJasmineFixture, root, _; + var ewwSideEffects, jasmineFixture, originalAffix, originalJasmineDotFixture, originalJasmineFixture, root, _, _ref; root = this; originalJasmineFixture = root.jasmineFixture; + originalJasmineDotFixture = (_ref = root.jasmine) != null ? _ref.fixture : void 0; originalAffix = root.affix; _ = function(list) { return { @@ -25,8 +26,11 @@ }; }; root.jasmineFixture = function($) { - var $whatsTheRootOf, createNodes; - $.fn.createNodes = createNodes = function(selectorOptions, attach) { + var $whatsTheRootOf, affix, create, jasmineFixture, noConflict; + affix = function(selectorOptions) { + return create.call(this, selectorOptions, true); + }; + create = function(selectorOptions, attach) { var $top; $top = null; _(selectorOptions.split(/[ ](?=[^\]]*?(?:\[|$))/)).inject(function($parent, elementSelector) { @@ -43,8 +47,15 @@ }, $whatsTheRootOf(this)); return $top; }; - $.fn.affix = root.affix = function(selectorOptions) { - return createNodes.call(this, selectorOptions, true); + noConflict = function() { + var currentJasmineFixture, _ref1; + currentJasmineFixture = jasmine.fixture; + root.jasmineFixture = originalJasmineFixture; + if ((_ref1 = root.jasmine) != null) { + _ref1.fixture = originalJasmineDotFixture; + } + root.affix = originalAffix; + return currentJasmineFixture; }; $whatsTheRootOf = function(that) { if (that.jquery != null) { @@ -55,17 +66,23 @@ return $('
').appendTo('body'); } }; - afterEach(function() { + jasmineFixture = { + affix: affix, + create: create, + noConflict: noConflict + }; + ewwSideEffects(jasmineFixture); + return jasmineFixture; + }; + ewwSideEffects = function(jasmineFixture) { + var _ref1; + if ((_ref1 = root.jasmine) != null) { + _ref1.fixture = jasmineFixture; + } + $.fn.affix = root.affix = jasmineFixture.affix; + return afterEach(function() { return $('#jasmine_content').remove(); }); - $.jasmine = { - noConflict: function() { - root.jasmineFixture = originalJasmineFixture; - root.affix = originalAffix; - return this; - } - }; - return $.jasmine; }; if ($) { return jasmineFixture = root.jasmineFixture($); diff --git a/dist/jasmine-fixture.min.js b/dist/jasmine-fixture.min.js index a430eda..470ced3 100644 --- a/dist/jasmine-fixture.min.js +++ b/dist/jasmine-fixture.min.js @@ -1,5 +1,5 @@ -/* jasmine-fixture - 1.1.0 +/* jasmine-fixture - 1.2.0 * Makes injecting HTML snippets into the DOM easy & clean! * https://github.com/searls/jasmine-fixture */ -(function(){var a,b=[].slice;!function(c){var d,e,f,g,h;return g=this,f=g.jasmineFixture,e=g.affix,h=function(a){return{inject:function(b,c){var d,e,f,g;for(g=[],e=0,f=a.length;f>e;e++)d=a[e],g.push(c=b(c,d));return g}}},g.jasmineFixture=function(b){var c,d;return b.fn.createNodes=d=function(d,e){var f;return f=null,h(d.split(/[ ](?=[^\]]*?(?:\[|$))/)).inject(function(c,d){var g;return">"===d?c:(g=a(b,d),(e||f)&&g.appendTo(c),f||(f=g),g)},c(this)),f},b.fn.affix=g.affix=function(a){return d.call(this,a,!0)},c=function(a){return null!=a.jquery?a:b("#jasmine_content").length>0?b("#jasmine_content"):b('').appendTo("body")},afterEach(function(){return b("#jasmine_content").remove()}),b.jasmine={noConflict:function(){return g.jasmineFixture=f,g.affix=e,this}},b.jasmine},c?d=g.jasmineFixture(c):g.affix=function(){var a;if(a=window.jQuery||window.$,null!=a)return d=g.jasmineFixture(a),affix.call.apply(affix,[this].concat(b.call(arguments)));throw new Error("jasmine-fixture requires jQuery to be defined at window.jQuery or window.$")}}(window.jQuery||window.$),a=function(){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y;return a=function(j,k,l,n,o){var p,q,r,s,t,v,x,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O;if(j.isPlainObject(k)?p=k.main:(p=k,k={main:p}),J=p,void 0===o&&(o={}),"!"===p.charAt(0)||j.isArray(l)){for(j.isArray(l)?E=p:(I=g(p,"!"),I=I.substring(I.indexOf(":")+1,I.length-1),E=i(p));"@"===E.charAt(0);)E=i("!for:!"+h(E,k));O=k,O.main=E,B=j(),"!for:"===p.substring(0,5)||j.isArray(l)?(!j.isArray(l)&&I.indexOf(":")>0&&(F=I.substring(0,I.indexOf(":")),I=I.substr(I.indexOf(":")+1)),q=j.isArray(l)?l:l[I],N=O.main,(j.isArray(q)||j.isPlainObject(q))&&j.map(q,function(b,c){var d;return O.main=N,void 0!==F&&(o[F]=c),j.isPlainObject(b)||(b={value:b}),d=a(j,O,b,n,o),0!==B.length?j.each(d,function(a,b){return B.push(b)}):void 0}),p=j.isArray(l)?"":p.substr(I.length+6+E.length)):"!if:"===p.substring(0,4)&&(L=f("!"+I+"!",l,o),("undefined"!==L||"false"!==L||""!==L)&&(B=a(j,O,l,n,o)),p=p.substr(I.length+5+E.length)),k.main=p}else if("("===p.charAt(0))K=g(p,"(",")"),G=K.substring(1,K.length-1),p=p.substr(K.length),O=k,O.main=G,B=a(j,O,l,n,o);else{if(A=p.match(y),r=A[0],0===r.length)return"";if(r.indexOf("@")>=0)return p=h(p,k),O=k,O.main=p,a(j,O,l,n,o);r=f(r,l,o),t=e(j,r),u.test(r)&&(x=u.exec(r)[1]),s=d(r,l),z="{"===r.charAt(0)?"span":"div","#"!==p.charAt(0)&&"."!==p.charAt(0)&&"{"!==p.charAt(0)&&(z=w.exec(r)[1]),-1!==r.search(m)&&(v=r.match(m)[1]),s=j.extend(s,{id:x,"class":t,html:v}),B=j("<"+z+">",s),B.attr(s),B=c(r,B,n),B=b(r,B,l),p=p.substr(A[0].length),k.main=p}return p.length>0&&(">"===p.charAt(0)&&("("===p.charAt(1)?(N=g(p.substr(1),"(",")"),p=p.substr(N.length+1)):"!"===p.charAt(1)?(I=g(p.substr(1),"!"),E=i(p.substr(1)),N=I+E,p=p.substr(N.length+1)):(H=Math.max(p.indexOf("+"),p.length),N=p.substring(1,H),p=p.substr(H)),O=k,O.main=N,D=j(a(j,O,l,n,o)),D.appendTo(B)),"+"===p.charAt(0)&&(O=k,O.main=p.substr(1),C=a(j,O,l,n,o),j.each(C,function(a,b){return B.push(b)}))),M=B},b=function(a,b,c){var d,e,f;if(0===a.search(q))return b;if(d=a.match(q),null===d)return b;for(e=0;e