11/*!
22 * angular-ui-scroll
33 * 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
55 * License: MIT
66 */
77
@@ -415,7 +415,6 @@ angular.module('ui.scroll', []).directive('uiScrollViewport', function () {
415415 }
416416
417417 function Adapter ( $attr , viewport , buffer , adjustBuffer , element ) {
418- var hasViewport = ! ! viewport . scope ( ) ;
419418 var viewportScope = viewport . scope ( ) || $rootScope ;
420419 var disabled = false ;
421420 var self = this ;
@@ -525,28 +524,18 @@ angular.module('ui.scroll', []).directive('uiScrollViewport', function () {
525524 var target = match [ 1 ] ;
526525 var onControllerName = match [ 2 ] ;
527526
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 ) {
532528 var candidate = element ;
533529 while ( candidate . length ) {
534530 var candidateScope = candidate . scope ( ) ;
531+ // ng-controller's 'Controller As' parsing
535532 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 ) {
537534 scope = candidateScope ;
538535 return true ;
539536 }
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' ) {
550539 scope = candidateScope ;
551540 return true ;
552541 }
@@ -557,7 +546,7 @@ angular.module('ui.scroll', []).directive('uiScrollViewport', function () {
557546 if ( onControllerName ) {
558547 // 'on' syntax DOM parsing (adapter='adapter on ctrl')
559548 scope = null ;
560- parseNgCtrlAttrs ( onControllerName ) ;
549+ parseController ( onControllerName , true ) ;
561550 if ( ! scope ) {
562551 throw new Error ( 'Failed to locate target controller \'' + onControllerName + '\' to inject \'' + target + '\'' ) ;
563552 }
@@ -567,9 +556,7 @@ angular.module('ui.scroll', []).directive('uiScrollViewport', function () {
567556 var dotIndex = target . indexOf ( '.' ) ;
568557 if ( dotIndex > 0 ) {
569558 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 ) ;
573560 }
574561 }
575562
0 commit comments