Skip to content

Commit d85131d

Browse files
authored
Fix bug related to Enzyme shallow rendering (#18)
* guard for existence of svg wrapper * update npm scripts
1 parent ec38ab1 commit d85131d

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
"deploy": "gh-pages -d public",
2626
"lint": "eslint src",
2727
"dist": "babel src --out-dir lib --ignore demos",
28-
"prepublish": "npm run dist"
28+
"predeploy": "npm run build",
29+
"prepublishOnly": "npm run dist"
2930
},
3031
"browserify": {
3132
"transform": [

src/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export default class MtSvgLines extends React.Component {
6868

6969
this._animStart = 0 // anim start timestamp
7070

71+
this._svgWrapper = null
7172
this._pathElems = []
7273
this._pathDataFrom = {}
7374
this._pathDataTo = {}
@@ -234,10 +235,10 @@ export default class MtSvgLines extends React.Component {
234235
}
235236

236237
/*
237-
* Acquire selection of SVG 'path' elems contained within
238+
* Acquire selection of 'path' elems contained within the SVG wrapper
238239
*/
239240
selectPathElems () {
240-
const svgEl = this._svgWrapper.getElementsByTagName('svg')[0]
241+
const svgEl = this._svgWrapper && this._svgWrapper.getElementsByTagName('svg')[0]
241242
return svgEl ? svgEl.querySelectorAll('path') : []
242243
}
243244

@@ -253,8 +254,8 @@ export default class MtSvgLines extends React.Component {
253254
[].forEach.call(pathElems, (pathEl, i) => {
254255
if (!this.hasSkipAttr(pathEl.attributes)) {
255256
const pathLengh = trimFloat(pathEl.getTotalLength() || 0)
256-
pathData.to[ i ] = 0
257257
pathData.from[ i ] = pathLengh
258+
pathData.to[ i ] = 0
258259
}
259260
})
260261

0 commit comments

Comments
 (0)