Skip to content

Commit

Permalink
refactor: improve update render
Browse files Browse the repository at this point in the history
  • Loading branch information
kmkzt committed May 17, 2020
1 parent 1bd17e4 commit a3f9a01
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ export class Renderer extends Svg {
}
/**
* render
* TODO: improve render
* TODO: XSS test
*/
public update() {
this.el.innerHTML = this.toElement().outerHTML
this.el.replaceChild(this.toElement(), this.el.childNodes[0])
}

public resize(param?: DOMRect) {
Expand Down
4 changes: 2 additions & 2 deletions src/svg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ export class Path {
strokeLinejoin: this.circuler ? 'round' : 'mitter'
}
}
public toElement(): HTMLElement {
const path = document.createElement('path')
public toElement(): SVGPathElement {
const path = document.createElementNS('http://www.w3.org/2000/svg', 'path')
path.setAttribute('stroke-width', String(this.strokeWidth))
path.setAttribute('stroke', this.stroke)
path.setAttribute('fill', this.fill)
Expand Down

0 comments on commit a3f9a01

Please sign in to comment.