mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-16 23:30:23 +00:00
parent
f9f95879f0
commit
04a62e83bc
4 changed files with 17 additions and 3 deletions
|
|
@ -191,6 +191,11 @@ Compiler.prototype = {
|
|||
var index = 0,
|
||||
template,
|
||||
parent = templateElement.parent();
|
||||
if (templateElement.length > 1) {
|
||||
// https://github.com/angular/angular.js/issues/338
|
||||
throw Error("Cannot compile multiple element roots: " +
|
||||
jqLite('<div>').append(templateElement.clone()).html());
|
||||
}
|
||||
if (parent && parent[0]) {
|
||||
parent = parent[0];
|
||||
for(var i = 0; i < parent.childNodes.length; i++) {
|
||||
|
|
|
|||
|
|
@ -40,8 +40,8 @@ describe('Binder', function(){
|
|||
});
|
||||
|
||||
it('ChangingRadioUpdatesModel', function(){
|
||||
var scope = this.compile('<input type="radio" name="model.price" value="A" checked>' +
|
||||
'<input type="radio" name="model.price" value="B">');
|
||||
var scope = this.compile('<div><input type="radio" name="model.price" value="A" checked>' +
|
||||
'<input type="radio" name="model.price" value="B"></div>');
|
||||
scope.$eval();
|
||||
assertEquals(scope.model.price, 'A');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -35,6 +35,15 @@ describe('compiler', function(){
|
|||
dealoc(scope);
|
||||
});
|
||||
|
||||
it('should not allow compilation of multiple roots', function(){
|
||||
expect(function(){
|
||||
compiler.compile('<div>A</div><span></span>');
|
||||
}).toThrow("Cannot compile multiple element roots: " + ie("<div>A</div><span></span>"));
|
||||
function ie(text) {
|
||||
return msie ? uppercase(text) : text;
|
||||
}
|
||||
});
|
||||
|
||||
it('should recognize a directive', function(){
|
||||
var e = jqLite('<div directive="expr" ignore="me"></div>');
|
||||
directives.directive = function(expression, element){
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ describe('$invalidWidgets', function() {
|
|||
|
||||
|
||||
it("should count number of invalid widgets", function(){
|
||||
var element = jqLite('<input name="price" ng:required ng:validate="number"></input>');
|
||||
var element = jqLite('<input name="price" ng:required ng:validate="number">');
|
||||
jqLite(document.body).append(element);
|
||||
scope = compile(element)();
|
||||
var $invalidWidgets = scope.$service('$invalidWidgets');
|
||||
|
|
|
|||
Loading…
Reference in a new issue