forked from kriszyp/xstyle
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjss.js
More file actions
34 lines (34 loc) · 933 Bytes
/
jss.js
File metadata and controls
34 lines (34 loc) · 933 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
define([], function(){
var objectWatch = {}.watch;
function JSS(data){
//TODO: record all rules so that additional JSS can be layered on top
return {
layout: function(layout, rule){
return {
render: function(domNode){
for(var i = 0; i < layout.length; i++){
var rule = layout[i];
var selector = rule.selector.substring(1);
var value = data.get ? data.get(selector) : data[selector];
if(data.watch != objectWatch){
data.watch(selector, function(name, oldValue, value){
renderValue(value)
});
}
function renderValue(value){
if(value !== undefined){
var target = document.createElement("div");
rule.renderInto(target);
}
}
rule.renderInto(target);
domNode.appendChild(target);
}
},
cssText: rule.selector.replace(/\//g, "[data-path=$1]")
}
}
};
}
return JSS;
});