1.1.0 • Published 9 years ago

ga-setattributes v1.1.0

Weekly downloads
-
License
MIT
Repository
bitbucket
Last release
9 years ago

#ga-setattributes

Node/CommonJS/AMD module and global function for setting attribute values on DOM elements.

##Installation

npm install ga-setattributes --save

##Usage

The script checks for each attribute if it is in the element already, i.e. if it is native. Otherwise element.setAttribute will be used – except for style and html which get a special treatment.

// Require
var setAttributes = require('ga-setattributes');

// Pass element and attributes literal
setAttributes(targetObject, {
	class: "foo bar",
	alt: "An image"
});

###Removing attributes Just pass null on an attribute you want to remove. Internally, element.removeAttribute will be used.

setAttributes(targetObject, {
	class: null
});

###Styles and HTML

setAttributes(targetObject, {
	html: "Click me",
	style: {
		color: "red"
	}
});

##Develop with Gulp

Use Git Flow, always work in develop branch.

  • Install development dependencies: npm install
  • Run gulp watch
  • Work in src/

Builds are now in dist/

1.1.0

9 years ago

1.0.0

9 years ago