Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

computed-style

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

computed-style

Cross-browser currentStyle/getComputedStyle implementation

  • 0.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
211K
increased by1.67%
Maintainers
1
Weekly downloads
 
Created
Source

computedStyle

Cross-browser currentStyle/getComputedStyle implementation

testling-ci badge

Getting Started

Download one of the available flavors:

  • Production version
  • Development version - Available via bower install computedStyle
  • CommonJS version - Available via npm install computed-style and component install twolfson/computedStyle
  • AMD version

In your web page:

<script src="dist/computedStyle.min.js"></script>
<script>
computedStyle(el, 'color'); // Returns color of the element
</script>

Documentation

computedStyle is a single purpose function

computedStyle(element, property);
/**
 * Cross-browser getComputedStyle
 * @param {HTMLElement} el Element to get property from
 * @param {String} prop Property to look up (DOM, zIndex, and CSS, z-index, formats accepted)
 * @returns Property from the browser
 *
 * @note These properties can vary from browser to browser.
 * For example, IE6 will return #FF0000 whereas Firefox will return rgb(255, 0, 0)
 * I have chosen to avoid this for this repo as it exits the single purpose
 * and jQuery follows the same approach.
 */

Examples

// Grab the z-index of an element
computedStyle(el, 'z-index');

// Grab the background-color of an element
computedStyle(el, 'background-color');

Donating

Support this project and others by twolfson via gratipay.

Support via Gratipay

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint your code using npm run lint and test via npm test.

License

Copyright (c) 2013 Todd Wolfson

Licensed under the MIT license.

Keywords

FAQs

Package last updated on 17 Dec 2014

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc