🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

base-svg-element

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

base-svg-element

A layer on base-element for SVG elements.

1.0.0
latest
Source
npm
Version published
Weekly downloads
6
100%
Maintainers
1
Weekly downloads
 
Created
Source

base-svg-element

A layer on base-element for SVG elements.

example

Create a SVG element:

var BaseElement = require('base-svg-element')
var inherits = require('inherits')

function Square (attach) {
  if (!(this instanceof Square)) return new Square(attach)
  BaseElement.call(this, attach)
  this.tagName = 'svg'
  this.className = 'square'
  this.viewBox = '0 0 100 100'
}
inherits(Square, BaseElement)

Square.prototype.render = function () {
  var h = this.html
  var vtree = h(this.tagName, this, [
    h('rect', { x: 10, y: 10, width: 80, height: 80 })
  ])
  return this.afterRender(vtree)
}

Use the SVG element:

var square = new Square(document.body)
square.render()

This will generate the following HTML:

<svg viewBox="0 0 100 100" class="square">
  <rect x="10" y="10" width="80" height="80"></rect>
</svg>

license

(c) 2015 Kyle Robinson Young. MIT License

Keywords

virtual

FAQs

Package last updated on 12 Jul 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts