source: node_modules/d3-selection/src/selection/style.js@ e4c61dd

Last change on this file since e4c61dd was e4c61dd, checked in by istevanoska <ilinastevanoska@…>, 6 months ago

Prototype 1.1

  • Property mode set to 100644
File size: 971 bytes
Line 
1import defaultView from "../window.js";
2
3function styleRemove(name) {
4 return function() {
5 this.style.removeProperty(name);
6 };
7}
8
9function styleConstant(name, value, priority) {
10 return function() {
11 this.style.setProperty(name, value, priority);
12 };
13}
14
15function styleFunction(name, value, priority) {
16 return function() {
17 var v = value.apply(this, arguments);
18 if (v == null) this.style.removeProperty(name);
19 else this.style.setProperty(name, v, priority);
20 };
21}
22
23export default function(name, value, priority) {
24 return arguments.length > 1
25 ? this.each((value == null
26 ? styleRemove : typeof value === "function"
27 ? styleFunction
28 : styleConstant)(name, value, priority == null ? "" : priority))
29 : styleValue(this.node(), name);
30}
31
32export function styleValue(node, name) {
33 return node.style.getPropertyValue(name)
34 || defaultView(node).getComputedStyle(node, null).getPropertyValue(name);
35}
Note: See TracBrowser for help on using the repository browser.