Skip to content

Commit ae2ff8a

Browse files
authored
Merge pull request #2 from singpolyma/cssinlinestyle
Add ElementCSSInlineStyle and CSSStyleDeclaration
2 parents 2c76d63 + 1df8cd1 commit ae2ff8a

File tree

5 files changed

+102
-0
lines changed

5 files changed

+102
-0
lines changed

src/Web/CSSOM/CSSStyleDeclaration.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
"use strict";
2+
3+
exports.cssText = function(style) {
4+
return function() {
5+
return style.cssText;
6+
};
7+
};
8+
9+
exports.setCssText = function(style) {
10+
return function(newCSS) {
11+
return function() {
12+
style.cssText = newCSS;
13+
};
14+
};
15+
};
16+
17+
exports.length = function(style) {
18+
return function() {
19+
return style.length;
20+
};
21+
};
22+
23+
exports.getPropertyPriority = function(style) {
24+
return function(propName) {
25+
return function() {
26+
return style.getPropertyPriority(propName);
27+
};
28+
};
29+
};
30+
31+
exports.getPropertyValue = function(style) {
32+
return function(propName) {
33+
return function() {
34+
return style.getPropertyValue(propName);
35+
};
36+
};
37+
};
38+
39+
exports.removeProperty = function(style) {
40+
return function(propName) {
41+
return function() {
42+
style.removeProperty(propName);
43+
};
44+
};
45+
};
46+
47+
exports.setProperty = function(style) {
48+
return function(propName) {
49+
return function(propValue) {
50+
return function() {
51+
style.setProperty(propName, propValue);
52+
};
53+
};
54+
};
55+
};
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
module Web.CSSOM.CSSStyleDeclaration
2+
( module Exports
3+
, length
4+
, getPropertyPriority
5+
, getPropertyValue
6+
, removeProperty
7+
, setProperty
8+
) where
9+
10+
import Prelude
11+
import Effect (Effect)
12+
import Web.CSSOM.Internal.Types (CSSStyleDeclaration) as Exports
13+
import Web.CSSOM.Internal.Types (CSSStyleDeclaration)
14+
15+
foreign import cssText :: CSSStyleDeclaration -> Effect String
16+
foreign import setCssText :: CSSStyleDeclaration -> String -> Effect Unit
17+
foreign import length :: CSSStyleDeclaration -> Effect Number
18+
19+
foreign import getPropertyPriority :: CSSStyleDeclaration -> String -> Effect String
20+
foreign import getPropertyValue :: CSSStyleDeclaration -> String -> Effect String
21+
foreign import removeProperty :: CSSStyleDeclaration -> String -> Effect Unit
22+
foreign import setProperty :: CSSStyleDeclaration -> String -> String -> Effect Unit
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
"use strict";
2+
3+
exports.style = function(el) {
4+
return function() {
5+
return el.style;
6+
};
7+
};
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module Web.CSSOM.ElementCSSInlineStyle
2+
( module Exports
3+
, style
4+
, fromHTMLElement
5+
) where
6+
7+
import Effect (Effect)
8+
import Unsafe.Coerce (unsafeCoerce)
9+
import Web.CSSOM.Internal.Types (ElementCSSInlineStyle) as Exports
10+
import Web.CSSOM.Internal.Types (ElementCSSInlineStyle, CSSStyleDeclaration)
11+
import Web.HTML.HTMLElement (HTMLElement)
12+
13+
foreign import style :: ElementCSSInlineStyle -> Effect CSSStyleDeclaration
14+
15+
fromHTMLElement :: HTMLElement -> ElementCSSInlineStyle
16+
fromHTMLElement = unsafeCoerce

src/Web/CSSOM/Internal/Types.purs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
module Web.CSSOM.Internal.Types where
22

3+
foreign import data CSSStyleDeclaration :: Type
34
foreign import data CSSStyleSheet :: Type
5+
foreign import data ElementCSSInlineStyle :: Type
46
foreign import data StyleSheetList :: Type

0 commit comments

Comments
 (0)