简体   繁体   中英

JavaScript error using paper-dropdown-menu

As of adding a paper-dropdown-menu to my Polymer web application I run into the following:

When clicking on the dropdown:

Uncaught TypeError
Polymer.Gestures.findOriginalTarget is not a function

after confirming, followed by:

Cannot set property 'right' of undefined

After confirming again the dropdown shows, albeit a bit out of shape.

What's the problem here ?

The findOriginalTarget does not seem to be set in your version of polymer. Polymer will probably be updated to support it. In the mean time, however, you can download new version of gestures that will add and replace this types of functions.

Alternatively, you can find _onTap line at paper-dropdown-menu/paper-dropdown-menu.html and replace function with:

  _onTap: function(event) {
    //if (Polymer.Gestures.findOriginalTarget(event) === this) {
    //  this.open();
    //}
    var targetElement = Polymer.dom(event).localTarget;
    if(targetElement === this){
      this.open();
    }
  },

This does work, but I did not test it with touch devices so I can't guarantee that (and I would appreciate feedback on this).

And lastly, if you don't care about _onTap event you could just set it to return false.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM