@@ -12678,6 +12678,47 @@ describe('$compile', function() {
12678
12678
} ) ;
12679
12679
} ) ;
12680
12680
12681
+ describe ( 'addPropertyContext' , function ( ) {
12682
+ function testProvider ( provider ) {
12683
+ module ( provider ) ;
12684
+ inject ( function ( $compile ) { /* done! */ } ) ;
12685
+ }
12686
+
12687
+ it ( 'should allow adding new properties' , function ( ) {
12688
+ testProvider ( function ( $compileProvider ) {
12689
+ $compileProvider . addPropertyContext ( 'div' , 'title' , 'mediaUrl' ) ;
12690
+ $compileProvider . addPropertyContext ( '*' , 'my-prop' , 'resourceUrl' ) ;
12691
+ } ) ;
12692
+ } ) ;
12693
+
12694
+ it ( 'should allow different sce types of a property on different element types' , function ( ) {
12695
+ testProvider ( function ( $compileProvider ) {
12696
+ $compileProvider . addPropertyContext ( 'div' , 'title' , 'mediaUrl' ) ;
12697
+ $compileProvider . addPropertyContext ( 'span' , 'title' , 'css' ) ;
12698
+ $compileProvider . addPropertyContext ( '*' , 'title' , 'resourceUrl' ) ;
12699
+ $compileProvider . addPropertyContext ( 'article' , 'title' , 'html' ) ;
12700
+ } ) ;
12701
+ } ) ;
12702
+
12703
+ it ( 'should throw \'ctxoverride\' when changing an existing context' , function ( ) {
12704
+ testProvider ( function ( $compileProvider ) {
12705
+ $compileProvider . addPropertyContext ( 'div' , 'title' , 'mediaUrl' ) ;
12706
+
12707
+ expect ( function ( ) {
12708
+ $compileProvider . addPropertyContext ( 'div' , 'title' , 'resourceUrl' ) ;
12709
+ } )
12710
+ . toThrowMinErr ( '$compile' , 'ctxoverride' , 'Property context \'div.title\' already set to \'mediaUrl\', cannot override to \'resourceUrl\'.' ) ;
12711
+ } ) ;
12712
+ } ) ;
12713
+
12714
+ it ( 'should setting the same property/element to the same value' , function ( ) {
12715
+ testProvider ( function ( $compileProvider ) {
12716
+ $compileProvider . addPropertyContext ( 'div' , 'title' , 'mediaUrl' ) ;
12717
+ $compileProvider . addPropertyContext ( 'div' , 'title' , 'mediaUrl' ) ;
12718
+ } ) ;
12719
+ } ) ;
12720
+ } ) ;
12721
+
12681
12722
12682
12723
describe ( 'when an attribute has an underscore-separated name' , function ( ) {
12683
12724
0 commit comments