1
1
/*!
2
2
* angular-ui-scroll
3
3
* https://github.com/angular-ui/ui-scroll.git
4
- * Version: 1.5.1 -- 2016-11-04T01:55:55.663Z
4
+ * Version: 1.5.1 -- 2016-11-07T22:33:16.326Z
5
5
* License: MIT
6
6
*/
7
7
@@ -415,7 +415,6 @@ angular.module('ui.scroll', []).directive('uiScrollViewport', function () {
415
415
}
416
416
417
417
function Adapter ( $attr , viewport , buffer , adjustBuffer , element ) {
418
- var hasViewport = ! ! viewport . scope ( ) ;
419
418
var viewportScope = viewport . scope ( ) || $rootScope ;
420
419
var disabled = false ;
421
420
var self = this ;
@@ -525,28 +524,18 @@ angular.module('ui.scroll', []).directive('uiScrollViewport', function () {
525
524
var target = match [ 1 ] ;
526
525
var onControllerName = match [ 2 ] ;
527
526
528
- // ng-controller attr based DOM parsing
529
- var parseNgCtrlAttrs = function parseNgCtrlAttrs ( controllerName ) {
530
- var as = arguments . length <= 1 || arguments [ 1 ] === undefined ? false : arguments [ 1 ] ;
531
-
527
+ var parseController = function parseController ( controllerName , on ) {
532
528
var candidate = element ;
533
529
while ( candidate . length ) {
534
530
var candidateScope = candidate . scope ( ) ;
531
+ // ng-controller's 'Controller As' parsing
535
532
var candidateName = ( candidate . attr ( 'ng-controller' ) || '' ) . match ( / ( \w (?: \w | \d ) * ) (?: \s + a s \s + ( \w (?: \w | \d ) * ) ) ? / ) ;
536
- if ( candidateName && candidateName [ as ? 2 : 1 ] === controllerName ) {
533
+ if ( candidateName && candidateName [ on ? 1 : 2 ] === controllerName ) {
537
534
scope = candidateScope ;
538
535
return true ;
539
536
}
540
- candidate = candidate . parent ( ) ;
541
- }
542
- } ;
543
-
544
- // scope based DOM pasrsing
545
- var parseScopes = function parseScopes ( controllerName ) {
546
- var candidate = element ;
547
- while ( candidate . length ) {
548
- var candidateScope = candidate . scope ( ) ;
549
- if ( candidateScope && candidateScope . hasOwnProperty ( controllerName ) && candidateScope [ controllerName ] . constructor . name === 'controller' ) {
537
+ // directive's/component's 'Controller As' parsing
538
+ if ( ! on && candidateScope && candidateScope . hasOwnProperty ( controllerName ) && candidateScope [ controllerName ] . constructor . name === 'controller' ) {
550
539
scope = candidateScope ;
551
540
return true ;
552
541
}
@@ -557,7 +546,7 @@ angular.module('ui.scroll', []).directive('uiScrollViewport', function () {
557
546
if ( onControllerName ) {
558
547
// 'on' syntax DOM parsing (adapter='adapter on ctrl')
559
548
scope = null ;
560
- parseNgCtrlAttrs ( onControllerName ) ;
549
+ parseController ( onControllerName , true ) ;
561
550
if ( ! scope ) {
562
551
throw new Error ( 'Failed to locate target controller \'' + onControllerName + '\' to inject \'' + target + '\'' ) ;
563
552
}
@@ -567,9 +556,7 @@ angular.module('ui.scroll', []).directive('uiScrollViewport', function () {
567
556
var dotIndex = target . indexOf ( '.' ) ;
568
557
if ( dotIndex > 0 ) {
569
558
controllerAsName = target . substr ( 0 , dotIndex ) ;
570
- if ( ! parseNgCtrlAttrs ( controllerAsName , true ) && ! hasViewport ) {
571
- parseScopes ( controllerAsName ) ; // the case of custom Directive/Component
572
- }
559
+ parseController ( controllerAsName , false ) ;
573
560
}
574
561
}
575
562
0 commit comments