简体   繁体   中英

NS_ERROR_FAILURE for path.getTotalLength

can you help me?

I make a loop on several "path" elements :

$.each($('path'), function(i, path){

var length = path.getTotalLength();

})

When the path is null (space character) I have this error on mozilla firefox :

NS_ERROR_FAILURE:
var length = path.getTotalLength();

I want to add a condition like this :

 $.each($('path'), function(i, path){

    if (path) {
    var length = path.getTotalLength();
    }

    })

But it doesn't work.

I fixed this recently in bug 1024860 . The fix will appear in Firefox 31. In the meantime you could wrap the call to check whether a path exists using element.hasAttribute() and then return 0.

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