1.1.0 • Published 7 years ago

get-specified-style.js v1.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

getSpecifiedStyle

getComputedStyle vs getSpecifiedStyle

Assume that viewport width is 1024px.

<div>hoge</div>
div {
	width: auto;
}
var element = document.querySelector('div');
var spedifiedStyle = getSpecifiedStyle(element);
var computedStyle = getComputedStyle(element);

console.log(spedifiedStyle.getPropertyValue('width'));//auto
console.log(computedStyle.getPropertyValue('width'));//1024px

Installation

bower install get-specified-style.js

or

yarn add get-specified-style.js

Load with script tag

<script src="/path/to/get-specified-style.js">

Usage

Almost the same as getComputedStyle

let style = getSpecifiedStyle(element[, pseudoElt]);

API

getPropertyValue

style.getPropertyValue(propertyName);//any value

getPropertyPriority

style.getPropertyPriority(propertyName);//'' or 'important'

getSpecificity

style.getSpecificity(propertyName);// 0~10000

Dependencies

  • specificity - Calculate the specificity of a CSS selector
1.1.0

7 years ago

1.0.17

7 years ago

1.0.16

7 years ago

1.0.15

7 years ago

1.0.14

7 years ago

1.0.13

7 years ago

1.0.12

7 years ago

1.0.11

7 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago