Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
feat(directive.style): Do not compile content of style element
Browse files Browse the repository at this point in the history
  • Loading branch information
vojtajina committed Feb 29, 2012
1 parent b37e8a2 commit d656d11
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/AngularPublic.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ function publishExternalAPI(angular){
form: ngFormDirective,
script: scriptTemplateLoader,
select: selectDirective,
style: styleDirective,
option: optionDirective,
ngBind: ngBindDirective,
ngBindHtml: ngBindHtmlDirective,
Expand Down
6 changes: 6 additions & 0 deletions src/directives.js
Original file line number Diff line number Diff line change
Expand Up @@ -969,3 +969,9 @@ var ngTranscludeDirective = valueFn({
});
}]
});


var styleDirective = valueFn({
restrict: 'E',
terminal: true
});
24 changes: 24 additions & 0 deletions test/directivesSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -557,4 +557,28 @@ describe("directive", function() {
expect(element.hasClass('bar')).toBe(true);
}));
});


describe('style', function() {

it('should not compile style element', inject(function($compile, $rootScope) {
element = jqLite('<style type="text/css">should {{notBound}}</style>');
$compile(element)($rootScope);
$rootScope.$digest();

// read innerHTML and trim to pass on IE8
expect(trim(element[0].innerHTML)).toBe('should {{notBound}}');
}));


it('should compile content of element with style attr', inject(function($compile, $rootScope) {
element = jqLite('<div style="some">{{bind}}</div>');
$compile(element)($rootScope);
$rootScope.$apply(function() {
$rootScope.bind = 'value';
});

expect(element.text()).toBe('value');
}));
});
});

0 comments on commit d656d11

Please sign in to comment.