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

$mdutil.findFocusTarget uses scope() which will not work if debug information is turned off #6474

Closed
geersch opened this issue Dec 28, 2015 · 1 comment
Assignees
Labels
P1: urgent Urgent issues that should be addressed in the next minor or patch release. pr: merge ready This PR is ready for a caretaker to review
Milestone

Comments

@geersch
Copy link

geersch commented Dec 28, 2015

function scanForFocusable(target, selector) {
    var elFound, items = target[0].querySelectorAll(selector);

    // Find the last child element with the focus attribute
    if ( items && items.length ){
      var EXP_ATTR = /\s*\[?([\-a-z]*)\]?\s*/i;
      var matches = EXP_ATTR.exec(selector);
      var attribute = matches ? matches[1] : null;

      items.length && angular.forEach(items, function(it) {
        it = angular.element(it);

        // If the expression evaluates to FALSE, then it is not focusable target
        var focusExpression = it[0].getAttribute(attribute);
        var isFocusable = !focusExpression || !$mdUtil.validateScope(it) ? true :
                          (it.scope().$eval(focusExpression) !== false );

        if (isFocusable) elFound = it;
      });
    }
    return elFound;
  }

The scope() function is only available if debug information is available! Evaluating the expression assigned to the focus attribute will break as soon as this is turned off in production.

@Frank3K
Copy link
Contributor

Frank3K commented Dec 28, 2015

This isn't the first issue where scope() is used, see also e.g. #6033. Is this some that can be tested automatically using e.g. karma?

@ThomasBurleson ThomasBurleson self-assigned this Jan 5, 2016
@ThomasBurleson ThomasBurleson modified the milestones: 1.0.2, 1.0.3 Jan 5, 2016
@ThomasBurleson ThomasBurleson added the P1: urgent Urgent issues that should be addressed in the next minor or patch release. label Jan 15, 2016
topherfangio added a commit to profoundry-us/material that referenced this issue Jan 19, 2016
A few places use `element.scope()` to retrieve the proper scope,
however, this is only available when Angular's debugging option
is enabled and thus fails in production.

Replace usages of `.scope()` in `util.js` and `datepicker.js`
with appropriate alternatives.

Fixes angular#6474.
topherfangio added a commit to profoundry-us/material that referenced this issue Jan 19, 2016
A few places use `element.scope()` to retrieve the proper scope,
however, this is only available when Angular's debugging option
is enabled and thus fails in production.

Replace usages of `.scope()` in `util.js` and `datepicker.js`
with appropriate alternatives.

Fixes angular#6474.
topherfangio added a commit to profoundry-us/material that referenced this issue Jan 19, 2016
A few places use `element.scope()` to retrieve the proper scope,
however, this is only available when Angular's debugging option
is enabled and thus fails in production.

Replace usages of `.scope()` in `util.js` and `datepicker.js`
with appropriate alternatives.

Fixes angular#6474.
topherfangio added a commit to profoundry-us/material that referenced this issue Jan 19, 2016
A few places use `element.scope()` to retrieve the proper scope,
however, this is only available when Angular's debugging option
is enabled and thus fails in production.

Replace usages of `.scope()` in `util.js` and `datepicker.js`
with appropriate alternatives.

Fixes angular#6474.
@topherfangio topherfangio added the pr: merge ready This PR is ready for a caretaker to review label Jan 20, 2016
topherfangio added a commit to profoundry-us/material that referenced this issue Jan 21, 2016
A few places use `element.scope()` to retrieve the proper scope,
however, this is only available when Angular's debugging option
is enabled and thus fails in production.

Replace usages of `.scope()` in `util.js` and `datepicker.js`
with appropriate alternatives. Remove unused function
`$mdUtil.validateScope()`.

Fixes angular#6474.
@ThomasBurleson ThomasBurleson modified the milestones: 1.0.3, 1.0.4 Jan 22, 2016
ErinCoughlan pushed a commit to ErinCoughlan/material that referenced this issue Feb 9, 2016
A few places use `element.scope()` to retrieve the proper scope,
however, this is only available when Angular's debugging option
is enabled and thus fails in production.

Replace usages of `.scope()` in `util.js` and `datepicker.js`
with appropriate alternatives. Remove unused function
`$mdUtil.validateScope()`.

Fixes angular#6474.

  Closes angular#6770
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P1: urgent Urgent issues that should be addressed in the next minor or patch release. pr: merge ready This PR is ready for a caretaker to review
Projects
None yet
Development

No branches or pull requests

4 participants