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

md-list-item - Cannot read property 'hasAttribute' of undefined #2337

Closed
cognitronic opened this issue Apr 15, 2015 · 4 comments
Closed

md-list-item - Cannot read property 'hasAttribute' of undefined #2337

cognitronic opened this issue Apr 15, 2015 · 4 comments
Assignees
Milestone

Comments

@cognitronic
Copy link

Hello,

The following code, which worked before I just upgraded to v0.9.0-rc1, is now throwing: typeError - cannot read property 'hasAttribute' of undefined.

                                    <md-list-item ng-repeat="(key, value) in datasource.entities track by $index">
                                        <div class="fd-bottom-padding" flex layout="row" ng-if="value == 0">
                                            <div flex>
                                                <p>Data has not yet been received for processing.</p>
                                            </div>
                                        </div>
                                        <div class="fd-bottom-padding" flex layout="row" ng-if="value != 0">
                                            <div flex="10" layout="column" layout-align="center center">
                                                <ng-md-icon size="38" icon="my_library_books"></ng-md-icon>
                                            </div>
                                            <div flex>
                                                <h3>{{ key }}</h3>
                                                <p>Total records sent: {{ value }}</p>
                                            </div>
                                            <div>
                                                <md-button class="md-button" aria-label="Map To Template">
                                                    <md-tooltip md-direction="left">
                                                        Map To Template
                                                    </md-tooltip>
                                                    <ng-md-icon size="24" icon="play_circle_outline">
                                                    </ng-md-icon>
                                                </md-button>
                                            </div>
                                        </div>
                                    </md-list-item>

Angular-Material.js Line 7116 is where the problem is happening:

function computeProxies() {
          if (!$element.children()[0].hasAttribute('ng-click')) {
            angular.forEach(proxiedTypes, function(type) {
              angular.forEach($element[0].firstElementChild.querySelectorAll(type), function(child) {
                proxies.push(child);
              });
            });
          }
        }

I believe it's happening due to the ng-if on the first div inside the md-list-item. Is there another way I should be handling this, or is this a bug?

@ThomasBurleson ThomasBurleson added this to the 0.9.0 milestone Apr 15, 2015
@cognitronic
Copy link
Author

Just to confirm, if I change the ng-if to ng-show, no error is thrown.

@FingersCrossed
Copy link

I'm experiencing the same issue while trying to place an md-list in a left side nav container using Ionic (version 1.3.19).

<md-list name="side-menu-list" md-theme="docs-dark" class="side-menu">

  <md-list-item class="item" name="order">Order</md-list-item>
  <md-list-item class="item" name="store">Store</md-list-item>
  <md-list-item class="item" name="account">Account</md-list-item>
  <md-list-item class="item" name="feedback">Feedback</md-list-item>
  <md-list-item class="item" name="insta-pay">Insta-Pay</md-list-item>
  <md-list-item class="item" name="favorites">Favorites</md-list-item>
</md-list>

TypeError: Cannot read property 'hasAttribute' of undefined

@mattoz0
Copy link

mattoz0 commented Apr 23, 2015

This seems to have broken the computeClickable function just underneath this function. I will make a PR to make computeClickable also check for number of children before trying to apply a class to null.

@badripennati
Copy link

I am having this issue when one of the md-list-item is empty. For now, I was able to suppress the error by including an empty span tag in the md-list-item.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants