SVG numberOfItems属性不起作用

时间:2016-01-31 22:58:14

标签: javascript google-chrome svg

我们的网站在最新更新后突然停止使用Chrome(只是chrome)...

给出的错误是

Uncaught TypeError: Cannot read property 'numberOfItems' of undefined

这是使用numberOfItems属性的地方:

// Absolutize and parse path to array
  , parse: function(array) {
      /* if it's already is a patharray, no need to parse it */
      if (array instanceof SVG.PathArray) return array.valueOf()

      /* prepare for parsing */
      var i, il, x0, y0, x1, y1, x2, y2, s, seg, segs
        , x = 0
        , y = 0

      /* populate working path */
      SVG.parser.path.setAttribute('d', typeof array === 'string' ? array : arrayToString(array))

      /* get segments */
      segs = SVG.parser.path.pathSegList


      for (i = 0, il = segs.numberOfItems; i < il; ++i) {
        seg = segs.getItem(i)
        s = seg.pathSegTypeAsLetter
etc. (I didn't put the whole loop)

为什么SVG和Javascript在最新的Chrome更新后无法读取此属性?什么可以是一个很好的解决方案?

谢谢!

相关问题