diff --git a/Gruntfile.js b/Gruntfile.js index 4317b037e8..349cf42725 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -84,8 +84,16 @@ module.exports = function(grunt) { dist_tpls:{ src:['<%= dist %>/<%= filename %>-tpls-<%= pkg.version %>.js'], dest:'<%= dist %>/<%= filename %>-tpls-<%= pkg.version %>.min.js' + }, + dist_ieshiv: { + src: ['<%= dist %>/ieshiv-<%= pkg.version %>.js'], + dest: '<%= dist %>/ieshiv-<%= pkg.version %>.min.js' } }, + ieshiv: { + src: 'misc/ieshiv.tpl.js', + dest: '<%= dist %>/ieshiv-<%= pkg.version %>.js' + }, html2js: { dist: { options: { @@ -254,7 +262,26 @@ module.exports = function(grunt) { grunt.config('concat.dist_tpls.src', grunt.config('concat.dist_tpls.src') .concat(srcFiles).concat(tpljsFiles)); - grunt.task.run(['concat', 'uglify']); + grunt.task.run(['concat', 'ieshiv', 'uglify']); + }); + + grunt.registerTask('ieshiv', 'Create the ieshiv file, based on the current build', function() { + var directiveNames = []; + var directiveDeclarations = grunt.file.read(grunt.config('concat.dist.dest')).match(/\.directive\([^'"]*('|")[^'"]*('|")/g); + + directiveDeclarations.forEach(function(match) { + directiveNames.push(/('|")([^'"]+)('|")/.exec(match)[2]); + }); + + grunt.file.write( + grunt.config('ieshiv.dest'), + grunt.template.process(grunt.file.read(grunt.config('ieshiv.src')), {data: { + directives: '"' + directiveNames.join('", "') + '"', + version : grunt.config('pkg.version') + }}) + ); + + grunt.log.writeln('File "' + grunt.config('ieshiv.dest') + '" created.'); }); grunt.registerTask('test', 'Run tests on singleRun karma server', function() { diff --git a/karma.conf.js b/karma.conf.js index 15d329e4ec..03c2f73bcd 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -10,12 +10,16 @@ files = [ 'misc/test-lib/angular.js', 'misc/test-lib/angular-mocks.js', 'misc/test-lib/helpers.js', + 'misc/test-lib/es5-shim.min.js', + 'dist/ieshiv-*.js', 'src/**/*.js', 'template/**/*.js' ]; // list of files to exclude exclude = [ + // exclude the ieshiv minified version to prevent loading it twice + 'dist/ieshiv-*.min.js' ]; // Start these browsers, currently available: diff --git a/misc/demo/index.html b/misc/demo/index.html index 374acc5cb9..53f7cf4f16 100644 --- a/misc/demo/index.html +++ b/misc/demo/index.html @@ -6,6 +6,15 @@ + + @@ -157,6 +166,20 @@

Installation

angular.module('myModule', ['ui.bootstrap']);

You can fork one of the plunkers from this page to see a working example of what is described here.

+

IE8 compatibility

+

To be able to use this library on Internet Explorer 8 you must also include: +

+ +

You can include them inside your site like this: +

+
diff --git a/misc/ieshiv.tpl.js b/misc/ieshiv.tpl.js new file mode 100644 index 0000000000..4d65eca3cc --- /dev/null +++ b/misc/ieshiv.tpl.js @@ -0,0 +1,39 @@ +// READ: http://docs.angularjs.org/guide/ie + +// The ieshiv takes care of ui.bootstrap.* directives; it's dynamically generated +// using the current version of the framework + +// +// +// Version: <%= version %> +// + +(function () { + + var tags = [<%= directives %>]; + + var toCustomElements = function (str) { + var result = []; + var dashed = str.replace(/([A-Z])/g, function ($1) { + return " " + $1.toLowerCase(); + }); + var tokens = dashed.split(' '); + var dirname = tokens.join('-'); + + result.push(dirname); + result.push("x-" + dirname); + result.push("data-" + dirname); + return result; + }; + + for (var i = 0, tlen = tags.length; i < tlen; i++) { + var customElements = toCustomElements(tags[i]); + for (var j = 0, clen = customElements.length; j < clen; j++) { + var customElement = customElements[j]; + document.createElement(customElement); + } + } + +})(); \ No newline at end of file diff --git a/misc/test-lib/es5-shim.min.js b/misc/test-lib/es5-shim.min.js new file mode 100755 index 0000000000..ea01ac4779 --- /dev/null +++ b/misc/test-lib/es5-shim.min.js @@ -0,0 +1,17 @@ +(function(o){"function"==typeof define?define(o):"function"==typeof YUI?YUI.add("es5",o):o()})(function(){function o(){}function v(a){a=+a;a!==a?a=0:0!==a&&(a!==1/0&&a!==-(1/0))&&(a=(0>>0;if(h(a)!="[object Function]")throw new TypeError;for(;++e>>0,f=Array(e);if(h(a)!="[object Function]")throw new TypeError(a+" is not a function");for(var g=0;g>>0,f=[],g;if(h(a)!="[object Function]")throw new TypeError(a+" is not a function");for(var i=0;i>>0;if(h(a)!="[object Function]")throw new TypeError(a+" is not a function");for(var f=0;f>>0;if(h(a)!="[object Function]")throw new TypeError(a+" is not a function");for(var f=0;f>>0;if(h(a)!="[object Function]")throw new TypeError(a+ +" is not a function");if(!c&&arguments.length==1)throw new TypeError("reduce of empty array with no initial value");var e=0,f;if(arguments.length>=2)f=arguments[1];else{do{if(e in d){f=d[e++];break}if(++e>=c)throw new TypeError("reduce of empty array with no initial value");}while(1)}for(;e>>0;if(h(a)!= +"[object Function]")throw new TypeError(a+" is not a function");if(!c&&arguments.length==1)throw new TypeError("reduceRight of empty array with no initial value");var e,c=c-1;if(arguments.length>=2)e=arguments[1];else{do{if(c in d){e=d[c--];break}if(--c<0)throw new TypeError("reduceRight of empty array with no initial value");}while(1)}do c in this&&(e=a.call(void 0,e,d[c],c,b));while(c--);return e});if(!Array.prototype.indexOf||-1!=[0,1].indexOf(1,2))Array.prototype.indexOf=function(a){var b=l&& +h(this)=="[object String]"?this.split(""):n(this),d=b.length>>>0;if(!d)return-1;var c=0;arguments.length>1&&(c=v(arguments[1]));for(c=c>=0?c:Math.max(0,d+c);c>>0;if(!d)return-1;var c=d-1;arguments.length>1&&(c=Math.min(c,v(arguments[1])));for(c=c>=0?c:d-Math.abs(c);c>=0;c--)if(c in b&& +a===b[c])return c;return-1};if(!Object.keys){var w=!0,x="toString toLocaleString valueOf hasOwnProperty isPrototypeOf propertyIsEnumerable constructor".split(" "),A=x.length,r;for(r in{toString:null})w=!1;Object.keys=function(a){if(typeof a!="object"&&typeof a!="function"||a===null)throw new TypeError("Object.keys called on a non-object");var b=[],d;for(d in a)t(a,d)&&b.push(d);if(w)for(d=0;d9999?"+":"")+("00000"+Math.abs(c)).slice(0<=c&&c<=9999?-4:-6);for(b=a.length;b--;){d=a[b];d<10&&(a[b]="0"+d)}return c+"-"+a.slice(0,2).join("-")+"T"+a.slice(2).join(":")+"."+("000"+this.getUTCMilliseconds()).slice(-3)+ +"Z"};r=!1;try{r=Date.prototype.toJSON&&null===(new Date(NaN)).toJSON()&&-1!==(new Date(-621987552E5)).toJSON().indexOf("-000001")&&Date.prototype.toJSON.call({toISOString:function(){return true}})}catch(H){}r||(Date.prototype.toJSON=function(){var a=Object(this),b;a:if(s(a))b=a;else{b=a.valueOf;if(typeof b==="function"){b=b.call(a);if(s(b))break a}b=a.toString;if(typeof b==="function"){b=b.call(a);if(s(b))break a}throw new TypeError;}if(typeof b==="number"&&!isFinite(b))return null;b=a.toISOString; +if(typeof b!="function")throw new TypeError("toISOString property is not callable");return b.call(a)});var g=Date,m=function(a,b,d,c,e,f,h){var i=arguments.length;if(this instanceof g){i=i==1&&String(a)===a?new g(m.parse(a)):i>=7?new g(a,b,d,c,e,f,h):i>=6?new g(a,b,d,c,e,f):i>=5?new g(a,b,d,c,e):i>=4?new g(a,b,d,c):i>=3?new g(a,b,d):i>=2?new g(a,b):i>=1?new g(a):new g;i.constructor=m;return i}return g.apply(this,arguments)},u=function(a,b){var d=b>1?1:0;return B[b]+Math.floor((a-1969+d)/4)-Math.floor((a- +1901+d)/100)+Math.floor((a-1601+d)/400)+365*(a-1970)},C=RegExp("^(\\d{4}|[+-]\\d{6})(?:-(\\d{2})(?:-(\\d{2})(?:T(\\d{2}):(\\d{2})(?::(\\d{2})(?:\\.(\\d{3}))?)?(Z|(?:([-+])(\\d{2}):(\\d{2})))?)?)?)?$"),B=[0,31,59,90,120,151,181,212,243,273,304,334,365],j;for(j in g)m[j]=g[j];m.now=g.now;m.UTC=g.UTC;m.prototype=g.prototype;m.prototype.constructor=m;m.parse=function(a){var b=C.exec(a);if(b){var d=Number(b[1]),c=Number(b[2]||1)-1,e=Number(b[3]||1)-1,f=Number(b[4]||0),h=Number(b[5]||0),i=Number(b[6]|| +0),j=Number(b[7]||0),m=!b[4]||b[8]?0:Number(new g(1970,0)),k=b[9]==="-"?1:-1,l=Number(b[10]||0),b=Number(b[11]||0);if(f<(h>0||i>0||j>0?24:25)&&h<60&&i<60&&j<1E3&&c>-1&&c<12&&l<24&&b<60&&e>-1&&e').appendTo(document.body); })); afterEach(function () { + element.remove(); element = groups = scope = $compile = undefined; }); @@ -128,16 +131,12 @@ describe('accordion', function () { "" + "Content 1" + "Content 2" + - ""; - element = angular.element(tpl); - angular.element(document.body).append(element); + ""; + element.html(tpl); $compile(element)(scope); scope.$digest(); groups = element.find('.accordion-group'); }); - afterEach(function() { - element.remove(); - }); it('should create accordion groups with content', function () { expect(groups.length).toEqual(2); @@ -175,7 +174,7 @@ describe('accordion', function () { "" + "{{group.content}}" + ""; - element = angular.element(tpl); + element.html(tpl); model = [ {name: 'title 1', content: 'Content 1'}, {name: 'title 2', content: 'Content 2'} @@ -220,8 +219,8 @@ describe('accordion', function () { "" + "Content 1" + "Content 2" + - ""; - element = angular.element(tpl); + ""; + element.html(tpl); scope.open1 = false; scope.open2 = true; $compile(element)(scope); @@ -241,21 +240,16 @@ describe('accordion', function () { "" + "
{{item}}
" + "Static content" + - "
"; - element = angular.element(tpl); + ""; + element.html(tpl); scope.items = ['Item 1', 'Item 2', 'Item 3']; scope.open1 = true; scope.open2 = false; - angular.element(document.body).append(element); $compile(element)(scope); scope.$digest(); groups = element.find('.accordion-group'); }); - afterEach(function() { - element.remove(); - }); - it('should have visible group body when the group with isOpen set to true', function () { expect(findGroupBody(0)[0].clientHeight).not.toBe(0); expect(findGroupBody(1)[0].clientHeight).toBe(0); @@ -271,7 +265,8 @@ describe('accordion', function () { 'Body' + '' + ''; - element = $compile(tpl)(scope); + element.html(tpl); + $compile(element)(scope); scope.$digest(); groups = element.find('.accordion-group'); }); @@ -285,10 +280,20 @@ describe('accordion', function () { }); describe('accordion-heading, with repeating accordion-groups', function() { - it('should clone the accordion-heading for each group', function() { - element = $compile('{{x}}')(scope); + beforeEach(function() { + var tpl = + '' + + '' + + '{{x}}' + + '' + + ''; + element.html(tpl); + $compile(element)(scope); scope.$digest(); groups = element.find('.accordion-group'); + }); + + it('should clone the accordion-heading for each group', function() { expect(groups.length).toBe(3); expect(findGroupLink(0).text()).toBe('1'); expect(findGroupLink(1).text()).toBe('2'); diff --git a/src/carousel/carousel.js b/src/carousel/carousel.js index 4fb09b7e87..6a96deef1c 100644 --- a/src/carousel/carousel.js +++ b/src/carousel/carousel.js @@ -38,7 +38,7 @@ angular.module('ui.bootstrap.carousel', ['ui.bootstrap.transition']) if (self.currentSlide && angular.isString(direction) && !$scope.noTransition && nextSlide.$element) { //We shouldn't do class manip in here, but it's the same weird thing bootstrap does. need to fix sometime nextSlide.$element.addClass(direction); - nextSlide.$element[0].offsetWidth = nextSlide.$element[0].offsetWidth; //force reflow + var useless = nextSlide.$element[0].offsetWidth; //force reflow //Set all other slides to stop doing their stuff for the new transition angular.forEach(slides, function(slide) { diff --git a/src/carousel/test/carousel.spec.js b/src/carousel/test/carousel.spec.js index a962bc15dc..95cf99be31 100644 --- a/src/carousel/test/carousel.spec.js +++ b/src/carousel/test/carousel.spec.js @@ -11,7 +11,7 @@ describe('carousel', function() { })); describe('basics', function() { - var elm, scope, carouselScope; + var elm, scope; beforeEach(function() { scope = $rootScope.$new(); scope.slides = [ @@ -19,19 +19,21 @@ describe('carousel', function() { {active:false,content:'two'}, {active:false,content:'three'} ]; - elm = $compile( + var tpl = '' + '' + '{{slide.content}}' + '' + - '' - )(scope); - carouselScope = elm.scope(); + ''; + elm = angular.element('
').appendTo(document.body); + elm.html(tpl); + $compile(elm)(scope); scope.interval = 5000; scope.$apply(); }); afterEach(function() { scope.$destroy(); + elm.remove(); }); function testSlideActive(slideIndex) { @@ -171,10 +173,10 @@ describe('carousel', function() { testSlideActive(0); $timeout.flush(); testSlideActive(1); - elm.trigger('mouseenter'); + elm.find('div.carousel').trigger('mouseenter'); expect($timeout.flush).toThrow();//pause should cancel current timeout testSlideActive(1); - elm.trigger('mouseleave'); + elm.find('div.carousel').trigger('mouseleave'); $timeout.flush(); testSlideActive(2); }); diff --git a/src/progressbar/docs/demo.html b/src/progressbar/docs/demo.html index 8fbfb082f8..0b987b4f85 100644 --- a/src/progressbar/docs/demo.html +++ b/src/progressbar/docs/demo.html @@ -3,7 +3,7 @@

Static

-
+

Dynamic

diff --git a/src/progressbar/test/progressbar.spec.js b/src/progressbar/test/progressbar.spec.js index 24889e26e7..634737fda5 100644 --- a/src/progressbar/test/progressbar.spec.js +++ b/src/progressbar/test/progressbar.spec.js @@ -1,3 +1,12 @@ +(function() { + +var getInlineWidth = function(element) { + var style = element.attr('style'); + var width = /(^| )width: +([^;]+)(;|$)/i.exec(style)[2]; + + return width; +}; + describe('progressbar directive with no binding', function () { var $rootScope, element; beforeEach(module('ui.bootstrap.progressbar')); @@ -19,7 +28,7 @@ describe('progressbar directive with no binding', function () { }); it('has a "bar" element with expected width', function() { - expect(element.children().eq(0).css('width')).toBe('22%'); + expect(getInlineWidth(element.children().eq(0))).toBe('22%'); }); }); @@ -45,23 +54,23 @@ describe('progressbar directive with data-binding', function () { }); it('has a "bar" element with expected width', function() { - expect(element.children().eq(0).css('width')).toBe('33%'); + expect(getInlineWidth(element.children().eq(0))).toBe('33%'); }); it('changes width when bind value changes', function() { $rootScope.percent = 55; $rootScope.$digest(); expect(element.children().length).toBe(1); - expect(element.children().eq(0).css('width')).toBe('55%'); + expect(getInlineWidth(element.children().eq(0))).toBe('55%'); expect(element.children().eq(0).hasClass('bar')).toBe(true); $rootScope.percent += 11; $rootScope.$digest(); - expect(element.children().eq(0).css('width')).toBe('66%'); + expect(getInlineWidth(element.children().eq(0))).toBe('66%'); $rootScope.percent = 0; $rootScope.$digest(); - expect(element.children().eq(0).css('width')).toBe('0%'); + expect(getInlineWidth(element.children().eq(0))).toBe('0%'); }); it('can handle correctly objects value && class', function() { @@ -75,7 +84,7 @@ describe('progressbar directive with data-binding', function () { expect(element.hasClass('progress')).toBe(true); var barElement = element.children().eq(0); - expect(barElement.css('width')).toBe('45%'); + expect(getInlineWidth(barElement)).toBe('45%'); expect(barElement.hasClass('bar')).toBe(true); expect(barElement.hasClass('bar-warning')).toBe(true); }); @@ -106,9 +115,9 @@ describe('stacked progressbar directive', function () { }); it('has a elements with expected width', function() { - expect(element.children().eq(0).css('width')).toBe('12%'); - expect(element.children().eq(1).css('width')).toBe('22%'); - expect(element.children().eq(2).css('width')).toBe('33%'); + expect(getInlineWidth(element.children().eq(0))).toBe('12%'); + expect(getInlineWidth(element.children().eq(1))).toBe('22%'); + expect(getInlineWidth(element.children().eq(2))).toBe('33%'); }); it('changes width when bind value changes', function() { @@ -116,9 +125,9 @@ describe('stacked progressbar directive', function () { $rootScope.$digest(); expect(element.children().length).toBe(3); - expect(element.children().eq(0).css('width')).toBe('12%'); - expect(element.children().eq(1).css('width')).toBe('35%'); - expect(element.children().eq(2).css('width')).toBe('33%'); + expect(getInlineWidth(element.children().eq(0))).toBe('12%'); + expect(getInlineWidth(element.children().eq(1))).toBe('35%'); + expect(getInlineWidth(element.children().eq(2))).toBe('33%'); }); it('can remove bars', function() { @@ -127,8 +136,8 @@ describe('stacked progressbar directive', function () { expect(element.children().length).toBe(2); - expect(element.children().eq(0).css('width')).toBe('12%'); - expect(element.children().eq(1).css('width')).toBe('22%'); + expect(getInlineWidth(element.children().eq(0))).toBe('12%'); + expect(getInlineWidth(element.children().eq(1))).toBe('22%'); }); it('can handle correctly object changes', function() { @@ -143,17 +152,17 @@ describe('stacked progressbar directive', function () { var barElement; barElement = element.children().eq(0); - expect(barElement.css('width')).toBe('12%'); + expect(getInlineWidth(barElement)).toBe('12%'); expect(barElement.hasClass('bar')).toBe(true); expect(barElement.hasClass('bar-danger')).toBe(false); barElement = element.children().eq(1); - expect(barElement.css('width')).toBe('29%'); + expect(getInlineWidth(barElement)).toBe('29%'); expect(barElement.hasClass('bar')).toBe(true); expect(barElement.hasClass('bar-danger')).toBe(true); barElement = element.children().eq(2); - expect(barElement.css('width')).toBe('33%'); + expect(getInlineWidth(barElement)).toBe('33%'); expect(barElement.hasClass('bar')).toBe(true); expect(barElement.hasClass('bar-danger')).toBe(false); }); @@ -173,23 +182,23 @@ describe('stacked progressbar directive', function () { var barElement; barElement = element.children().eq(0); - expect(barElement.css('width')).toBe('15%'); + expect(getInlineWidth(barElement)).toBe('15%'); expect(barElement.hasClass('bar-info')).toBe(true); barElement = element.children().eq(1); - expect(barElement.css('width')).toBe('11%'); + expect(getInlineWidth(barElement)).toBe('11%'); expect(barElement.hasClass('bar-info')).toBe(false); barElement = element.children().eq(2); - expect(barElement.css('width')).toBe('9%'); + expect(getInlineWidth(barElement)).toBe('9%'); expect(barElement.hasClass('bar-danger')).toBe(true); barElement = element.children().eq(3); - expect(barElement.css('width')).toBe('22%'); + expect(getInlineWidth(barElement)).toBe('22%'); expect(barElement.hasClass('bar-warning')).toBe(true); barElement = element.children().eq(4); - expect(barElement.css('width')).toBe('5%'); + expect(getInlineWidth(barElement)).toBe('5%'); expect(barElement.hasClass('bar-warning')).toBe(false); }); @@ -264,11 +273,11 @@ describe('stacked progressbar directive with auto-types', function () { }); it('has elements with expected width', function() { - expect(element.children().eq(0).css('width')).toBe('12%'); - expect(element.children().eq(1).css('width')).toBe('22%'); - expect(element.children().eq(2).css('width')).toBe('33%'); - expect(element.children().eq(3).css('width')).toBe('5%'); - expect(element.children().eq(4).css('width')).toBe('11%'); + expect(getInlineWidth(element.children().eq(0))).toBe('12%'); + expect(getInlineWidth(element.children().eq(1))).toBe('22%'); + expect(getInlineWidth(element.children().eq(2))).toBe('33%'); + expect(getInlineWidth(element.children().eq(3))).toBe('5%'); + expect(getInlineWidth(element.children().eq(4))).toBe('11%'); }); it('has elements with automatic types', function() { @@ -289,7 +298,7 @@ describe('stacked progressbar directive with auto-types', function () { var stackedTypes = config.stackedTypes; var bar = element.children().eq(1); - expect(bar.css('width')).toBe('18%'); + expect(getInlineWidth(bar)).toBe('18%'); expect(bar.hasClass('bar-' + stackedTypes[1])).toBe(false); expect(bar.hasClass('bar-something')).toBe(true); }); @@ -305,7 +314,7 @@ describe('stacked progressbar directive with auto-types', function () { var stackedTypes = config.stackedTypes; var bar = element.children().eq(1); - expect(bar.css('width')).toBe('18%'); + expect(getInlineWidth(bar)).toBe('18%'); expect(bar.hasClass('bar-' + stackedTypes[1])).toBe(false); expect(bar.hasClass('bar-something')).toBe(true); }); @@ -323,4 +332,6 @@ describe('stacked progressbar directive with auto-types', function () { expect(element.children().eq(2).hasClass('bar-success')).toBe(true); }); -}); \ No newline at end of file +}); + +})(); \ No newline at end of file diff --git a/src/tabs/tabs.js b/src/tabs/tabs.js index 2d3d0a5c62..64e042b511 100644 --- a/src/tabs/tabs.js +++ b/src/tabs/tabs.js @@ -134,6 +134,10 @@ function($parse, $http, $templateCache, $compile) { }; }]) +// This comment is needed by the "ieshiv" grunt task to correctly build +// the ieshiv file +//.directive('tabHeading') + .directive('tabHeadingTransclude', [function() { return { restrict: 'A', diff --git a/src/tabs/test/tabsSpec.js b/src/tabs/test/tabsSpec.js index 74002e152f..d57897f2cd 100644 --- a/src/tabs/test/tabsSpec.js +++ b/src/tabs/test/tabsSpec.js @@ -23,10 +23,16 @@ describe('tabs', function() { expect(c.eq(i).text().trim()).toEqual(contentsArray[i]); } } + + function tagsToLower(html) { + return html.replace(/<[^>]+>|<\/[^>]+>/g, function (m) { + return m.toLowerCase(); + }); + } describe('basics', function() { - + beforeEach(inject(function($compile, $rootScope) { scope = $rootScope.$new(); scope.first = '1'; @@ -34,22 +40,27 @@ describe('tabs', function() { scope.actives = {}; scope.selectFirst = jasmine.createSpy(); scope.selectSecond = jasmine.createSpy(); - elm = $compile([ - '
', - ' ', - ' ', - ' first content is {{first}}', - ' ', - ' ', - ' Second Tab {{second}}', - ' second content is {{second}}', - ' ', - ' ', - '
' - ].join('\n'))(scope); + elm = angular.element('
').appendTo(document.body); + var tpl = [ + '', + ' ', + ' first content is {{first}}', + ' ', + ' ', + ' Second Tab {{second}}', + ' second content is {{second}}', + ' ', + '' + ].join('\n'); + elm.html(tpl); + $compile(elm)(scope); scope.$apply(); - return elm; })); + + afterEach(function() { + elm.remove(); + elm = scope = undefined; + }); it('should create clickable titles', function() { var t = titles(); @@ -57,7 +68,7 @@ describe('tabs', function() { expect(t.find('a').eq(0).text()).toBe('First Tab 1'); //It should put the tab-heading element into the 'a' title expect(t.find('a').eq(1).children().is('tab-heading')).toBe(true); - expect(t.find('a').eq(1).children().html()).toBe('Second Tab 2'); + expect(tagsToLower(t.find('a').eq(1).children().html())).toBe('Second Tab 2'); }); it('should bind tabs content and set first tab active', function() { @@ -100,16 +111,24 @@ describe('tabs', function() { scope.tabs = [ makeTab(), makeTab(), makeTab(), makeTab() ]; - elm = $compile([ + elm = angular.element('
').appendTo(document.body); + var tpl = [ '', ' ', ' heading {{index}}', ' content {{$index}}', ' ', '' - ].join('\n'))(scope); + ].join('\n'); + elm.html(tpl); + $compile(elm)(scope); scope.$apply(); })); + + afterEach(function() { + elm.remove(); + elm = scope = undefined; + }); function titles() { return elm.find('ul.nav-tabs li'); @@ -167,7 +186,8 @@ describe('tabs', function() { scope = $rootScope.$new(); scope.myHtml = "hello, there!"; scope.value = true; - elm = $compile([ + elm = angular.element('
').appendTo(document.body); + var tpl = [ '', ' ', ' ', @@ -177,16 +197,23 @@ describe('tabs', function() { '
2
', '
3
', '
' - ].join('\n'))(scope); + ].join('\n'); + elm.html(tpl); + $compile(elm)(scope); scope.$apply(); })); + + afterEach(function() { + elm.remove(); + elm = scope = undefined; + }); function heading() { return elm.find('ul li a').children(); } it('should create a heading bound to myHtml', function() { - expect(heading().eq(0).html()).toBe("hello, there!"); + expect(tagsToLower(heading().eq(0).html())).toBe("hello, there!"); }); it('should hide and show the heading depending on value', function() { @@ -215,7 +242,8 @@ describe('tabs', function() { { title:"Title 2", available:true }, { title:"Title 3", available:true } ]; - elm = $compile([ + elm = angular.element('
').appendTo(document.body); + var tpl = [ '', ' ', '
div that makes troubles
', @@ -236,12 +264,19 @@ describe('tabs', function() { ' yet another span that may do evil', ' ', '
' - ].join('\n'))(scope); + ].join('\n'); + elm.html(tpl); + $compile(elm)(scope); scope.tabIsAvailable = function(tab) { return tab.available; }; })); + + afterEach(function() { + elm.remove(); + elm = scope = undefined; + }); it('should preserve correct ordering', function() { function titles() { @@ -354,11 +389,21 @@ describe('tabs', function() { describe('remove', function() { - it('should remove title tabs when elements are destroyed and change selection', inject(function($controller, $compile, $rootScope) { + beforeEach(inject(function($compile, $rootScope) { scope = $rootScope.$new(); - elm = $compile("Hellocontent {{i}}")(scope); + elm = angular.element('
').appendTo(document.body); + var tpl = "Hellocontent {{i}}"; + elm.html(tpl); + $compile(elm)(scope); scope.$apply(); + })); + + afterEach(function() { + elm.remove(); + elm = scope = undefined; + }); + it('should remove title tabs when elements are destroyed and change selection', function() { expectTitles(['1']); expectContents(['Hello']); @@ -376,6 +421,6 @@ describe('tabs', function() { expect(titles().eq(2)).toHaveClass('active'); expect(contents().eq(2)).toHaveClass('active'); - })); + }); }); }); diff --git a/src/tooltip/tooltip.js b/src/tooltip/tooltip.js index 2d4f85b4fa..79a8b2ac9d 100644 --- a/src/tooltip/tooltip.js +++ b/src/tooltip/tooltip.js @@ -93,14 +93,14 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position' ] ) var triggers = setTriggers( undefined ); var template = - '<'+ directiveName +'-popup '+ + '
'+ - ''; + '
'; return { restrict: 'EA', @@ -293,7 +293,7 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position' ] ) .directive( 'tooltipPopup', function () { return { - restrict: 'E', + restrict: 'EA', replace: true, scope: { content: '@', placement: '@', animation: '&', isOpen: '&' }, templateUrl: 'template/tooltip/tooltip-popup.html' @@ -306,7 +306,7 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position' ] ) .directive( 'tooltipHtmlUnsafePopup', function () { return { - restrict: 'E', + restrict: 'EA', replace: true, scope: { content: '@', placement: '@', animation: '&', isOpen: '&' }, templateUrl: 'template/tooltip/tooltip-html-unsafe-popup.html' diff --git a/src/typeahead/test/typeahead.spec.js b/src/typeahead/test/typeahead.spec.js index b69e4d5c9d..30ce05ba28 100644 --- a/src/typeahead/test/typeahead.spec.js +++ b/src/typeahead/test/typeahead.spec.js @@ -296,7 +296,7 @@ describe('typeahead tests', function () { var element = prepareInputEl("
"); changeInputValueTo(element, 'fo'); - var matchHighlight = findMatches(element).find('a').html(); + var matchHighlight = findMatches(element).find('a').html().toLowerCase(); expect(matchHighlight).toEqual('prefixfoo'); }); @@ -400,4 +400,4 @@ describe('typeahead tests', function () { }); }); -}); \ No newline at end of file +}); diff --git a/template/progressbar/progress.html b/template/progressbar/progress.html index d390e79f7d..a2c0c99b42 100644 --- a/template/progressbar/progress.html +++ b/template/progressbar/progress.html @@ -1 +1 @@ -
\ No newline at end of file +
\ No newline at end of file