mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
feat($compile): mark scope creation with ng-scope class
This commit is contained in:
parent
4a051efb89
commit
cb10ccc44f
3 changed files with 11 additions and 7 deletions
|
|
@ -195,7 +195,7 @@ function $CompileProvider($provide) {
|
|||
var element = cloneConnectFn
|
||||
? JQLitePrototype.clone.call(templateElement) // IMPORTANT!!!
|
||||
: templateElement;
|
||||
element.data('$scope', scope);
|
||||
element.data('$scope', scope).addClass('ng-scope');
|
||||
if (cloneConnectFn) cloneConnectFn(element, scope);
|
||||
if (linkingFn) linkingFn(scope, element, element);
|
||||
return element;
|
||||
|
|
@ -371,6 +371,7 @@ function $CompileProvider($provide) {
|
|||
|
||||
if (directive.scope) {
|
||||
assertNoDuplicate('new scope', newScopeDirective, directive, element);
|
||||
element.addClass('ng-scope');
|
||||
newScopeDirective = directive;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -261,7 +261,7 @@ describe("directive", function() {
|
|||
$rootScope.$digest();
|
||||
$rootScope.dynCls = 'foo';
|
||||
$rootScope.$digest();
|
||||
expect(element[0].className).toBe('ui-panel ui-selected foo');
|
||||
expect(element[0].className).toBe('ui-panel ui-selected ng-scope foo');
|
||||
}));
|
||||
|
||||
|
||||
|
|
@ -269,7 +269,7 @@ describe("directive", function() {
|
|||
element = $compile('<div class="panel bar" ng:class="dynCls"></div>')($rootScope);
|
||||
$rootScope.dynCls = 'panel';
|
||||
$rootScope.$digest();
|
||||
expect(element[0].className).toBe('panel bar');
|
||||
expect(element[0].className).toBe('panel bar ng-scope');
|
||||
}));
|
||||
|
||||
|
||||
|
|
@ -279,7 +279,7 @@ describe("directive", function() {
|
|||
$rootScope.$digest();
|
||||
$rootScope.dynCls = 'window';
|
||||
$rootScope.$digest();
|
||||
expect(element[0].className).toBe('bar window');
|
||||
expect(element[0].className).toBe('bar ng-scope window');
|
||||
}));
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -189,19 +189,21 @@ describe('$compile', function() {
|
|||
toEqual('<div factory-error linking-error template-error>');
|
||||
expect($exceptionHandler.errors[2][0]).toEqual('LinkingError');
|
||||
expect(ie($exceptionHandler.errors[2][1])).
|
||||
toEqual('<div factory-error linking-error template-error>');
|
||||
toEqual('<div class="ng-scope" factory-error linking-error template-error>');
|
||||
|
||||
|
||||
// crazy stuff to make IE happy
|
||||
function ie(text) {
|
||||
var list = [],
|
||||
parts;
|
||||
parts, elementName;
|
||||
|
||||
parts = lowercase(text).
|
||||
replace('<', '').
|
||||
replace('>', '').
|
||||
split(' ');
|
||||
elementName = parts.shift();
|
||||
parts.sort();
|
||||
parts.unshift(elementName);
|
||||
forEach(parts, function(value, key){
|
||||
if (value.substring(0,3) == 'ng-') {
|
||||
} else {
|
||||
|
|
@ -888,6 +890,7 @@ describe('$compile', function() {
|
|||
it('should allow creation of new scopes', inject(function($rootScope, $compile, log) {
|
||||
element = $compile('<div><span scope><a log></a></span></div>')($rootScope);
|
||||
expect(log).toEqual('LOG; log-002-001; 002');
|
||||
expect(element.find('span').hasClass('ng-scope')).toBe(true);
|
||||
}));
|
||||
|
||||
|
||||
|
|
@ -913,7 +916,7 @@ describe('$compile', function() {
|
|||
expect(function(){
|
||||
$compile('<div class="scope-a; scope-b"></div>');
|
||||
}).toThrow('Multiple directives [scopeA, scopeB] asking for new scope on: ' +
|
||||
'<' + (msie < 9 ? 'DIV' : 'div') + ' class="scope-a; scope-b">');
|
||||
'<' + (msie < 9 ? 'DIV' : 'div') + ' class="scope-a; scope-b ng-scope">');
|
||||
}));
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue