aboutsummaryrefslogtreecommitdiffstats
path: root/src/elements/Svg.js
diff options
context:
space:
mode:
authorSaivan <savian@me.com>2018-11-26 00:17:41 +1300
committerSaivan <savian@me.com>2018-11-26 00:17:41 +1300
commit617aa12304541cf1d80b2bf5567ac633958c38de (patch)
treec1082b4573625f93d18e82e6d5a0c4a40782993f /src/elements/Svg.js
parent599fda2f11c88b2c18d0cd0b57d4adeca20db2eb (diff)
downloadsvg.js-617aa12304541cf1d80b2bf5567ac633958c38de.tar.gz
svg.js-617aa12304541cf1d80b2bf5567ac633958c38de.zip
Reverted some of the lint rules after chatting with fuzzy
This commit reverts some of the rules we added on the linter, it changed a lot of code again... but these won't happen too often. Changes ======= - Modified the linter again
Diffstat (limited to 'src/elements/Svg.js')
-rw-r--r--src/elements/Svg.js68
1 files changed, 23 insertions, 45 deletions
diff --git a/src/elements/Svg.js b/src/elements/Svg.js
index 1326900..ab7d89f 100644
--- a/src/elements/Svg.js
+++ b/src/elements/Svg.js
@@ -11,90 +11,68 @@ import Defs from './Defs.js'
import { globals } from '../utils/window.js'
export default class Svg extends Container {
-
- constructor ( node ) {
-
- super( nodeOrNew( 'svg', node ), node )
+ constructor (node) {
+ super(nodeOrNew('svg', node), node)
this.namespace()
-
}
isRoot () {
-
return !this.node.parentNode
- || !( this.node.parentNode instanceof globals.window.SVGElement )
+ || !(this.node.parentNode instanceof globals.window.SVGElement)
|| this.node.parentNode.nodeName === '#document'
-
}
// Check if this is a root svg
// If not, call docs from this element
root () {
-
- if ( this.isRoot() ) return this
+ if (this.isRoot()) return this
return super.root()
-
}
// Add namespaces
namespace () {
-
- if ( !this.isRoot() ) return this.root().namespace()
+ if (!this.isRoot()) return this.root().namespace()
return this
- .attr( { xmlns: ns, version: '1.1' } )
- .attr( 'xmlns:xlink', xlink, xmlns )
- .attr( 'xmlns:svgjs', svgjs, xmlns )
-
+ .attr({ xmlns: ns, version: '1.1' })
+ .attr('xmlns:xlink', xlink, xmlns)
+ .attr('xmlns:svgjs', svgjs, xmlns)
}
// Creates and returns defs element
defs () {
+ if (!this.isRoot()) return this.root().defs()
- if ( !this.isRoot() ) return this.root().defs()
-
- return adopt( this.node.getElementsByTagName( 'defs' )[0] )
- || this.put( new Defs() )
-
+ return adopt(this.node.getElementsByTagName('defs')[0])
+ || this.put(new Defs())
}
// custom parent method
- parent ( type ) {
-
- if ( this.isRoot() ) {
-
+ parent (type) {
+ if (this.isRoot()) {
return this.node.parentNode.nodeName === '#document'
? null
- : adopt( this.node.parentNode )
-
+ : adopt(this.node.parentNode)
}
- return super.parent( type )
-
+ return super.parent(type)
}
clear () {
-
// remove children
- while ( this.node.hasChildNodes() ) {
-
- this.node.removeChild( this.node.lastChild )
-
+ while (this.node.hasChildNodes()) {
+ this.node.removeChild(this.node.lastChild)
}
return this
-
}
-
}
-registerMethods( {
+registerMethods({
Container: {
// Create nested svg document
- nested: wrapWithAttrCheck( function () {
-
- return this.put( new Svg() )
-
- } )
+ nested: wrapWithAttrCheck(function () {
+ return this.put(new Svg())
+ })
}
-} )
+})
-register( Svg, 'Svg', true )
+register(Svg, 'Svg', true)