Comparing version 1.0.6 to 1.1.0
24
index.js
@@ -21,5 +21,8 @@ var prefix = require('prefix-style') | ||
camel = detect(property) | ||
//may be false if CSS prop is unsupported | ||
if (camel) { | ||
if (camel) { | ||
if (value === undefined) | ||
return element.style[camel] | ||
if (typeof value === 'number') | ||
@@ -46,3 +49,3 @@ value = value + (suffixMap[camel]||'') | ||
module.exports = function() { | ||
function set() { | ||
'use strict'; | ||
@@ -53,2 +56,15 @@ if (arguments.length === 2) { | ||
style(arguments[0], arguments[1], arguments[2]) | ||
} | ||
} | ||
module.exports = set | ||
module.exports.set = set | ||
module.exports.get = function(element, properties) { | ||
if (Array.isArray(properties)) | ||
return properties.reduce(function(obj, prop) { | ||
obj[prop] = style(element, prop||'') | ||
return obj | ||
}, {}) | ||
else | ||
return style(element, properties||'') | ||
} |
{ | ||
"name": "dom-css", | ||
"version": "1.0.6", | ||
"version": "1.1.0", | ||
"description": "fast dom CSS styling", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# dom-css | ||
[![stable](http://badges.github.io/stability-badges/dist/stable.svg)](http://github.com/badges/stability-badges) | ||
[![Build Status](https://travis-ci.org/mattdesl/dom-css.svg?branch=master)](https://travis-ci.org/mattdesl/dom-css) [![stable](http://badges.github.io/stability-badges/dist/stable.svg)](http://github.com/badges/stability-badges) | ||
@@ -28,4 +28,12 @@ Small module for fast and reliable DOM styling. | ||
top: 0, | ||
marginTop: 0, | ||
position: 'absolute' | ||
}) | ||
//get the current style | ||
css.get(element, 'position') | ||
// -> 'absolute' | ||
css.get(element, ['left', 'marginTop']) | ||
// -> { left: '25px', marginTop: '0px' } | ||
``` | ||
@@ -40,2 +48,3 @@ | ||
#### `css(element, property, value)` | ||
#### `css.set(element, property, value)` | ||
@@ -45,5 +54,16 @@ Styles an element with the css `property` (dash or camel case) and a given value. `value` is a string, or a number to be suffixed with `'px'` (special cases, see below). | ||
#### `css(element, styles)` | ||
#### `css.set(element, styles)` | ||
A shorthand for setting multiple styles, where `styles` is an object containing `property:value` pairs. | ||
#### `css.get(element, prop)` | ||
Gets the inline style of element, where `prop` is a string (like `"borderRadius"`) or an array of strings. If an array of strings is given, an object is returned with key-value pairs representing the specified properties. | ||
```js | ||
css.get(div, ['width', 'height']) => { width: "20px", height: "40px" } | ||
``` | ||
*Note:* This does not provide the *computed* style! | ||
#### special cases | ||
@@ -50,0 +70,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6967
58
85