Skip to content

Commit 4b589e2

Browse files
committed
linting and tests passing
1 parent a2e0eb1 commit 4b589e2

27 files changed

+4608
-832
lines changed

.vscode/settings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"eslint.autoFixOnSave": true,
3+
"eslint.alwaysShowStatus": true
4+
}

client/dom.js

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,24 @@
1-
'use strict';
1+
'use strict'
22

33
exports.load = function (str) {
4-
return $(str);
5-
};
4+
return str
5+
}
66

77
exports.find = function ($domNode, selector) {
8-
var out = $domNode.filter(selector);;
9-
if (out.length > 0) { // filter doesnt catch em all.
10-
return out;
11-
}else {
12-
return $domNode.find(selector); // jquery
13-
}
14-
};
8+
console.log($domNode)
9+
return $domNode.querySelector(selector)
10+
}
1511

1612
// only available in the browser
1713
exports.getMarkup = function ($page) {
18-
var out = [];
19-
$page.each(function (i, item) {
20-
out.push(item.outerHTML);
21-
});
22-
return out.join('');
23-
};
14+
return $page
15+
}
16+
17+
exports.setMarkup = function ($node, markup) {
18+
$node.innerHTML = markup
19+
}
2420

2521
// jqueryify node
2622
exports.get = function (item) {
27-
return $(item);
28-
};
23+
return item
24+
}

examples/array.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
var sizlate = require('sizlate');
1+
var sizlate = require('sizlate')
22

3-
var html = '<ul><li></li></ul>';
3+
var html = '<ul><li></li></ul>'
44
var selectors = {
5-
'li': [
6-
'change links to this',
7-
'change links to this2',
8-
{
9-
'href': 'df',
10-
innerHTML: 'aaa'
11-
}
12-
]
13-
};
14-
var out = sizlate.render(html, selectors);
15-
console.log(out);
5+
'li': [
6+
'change links to this',
7+
'change links to this2',
8+
{
9+
'href': 'df',
10+
innerHTML: 'aaa'
11+
}
12+
]
13+
}
14+
var out = sizlate.render(html, selectors)
15+
console.log(out)

examples/className.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
var sizlate = require('sizlate');
1+
var sizlate = require('sizlate')
22

3-
var html = '<div><a class="class1"></a></div>';
3+
var html = '<div><a class="class1"></a></div>'
44
var selectors = {
5-
'div a': {
6-
className: 'class2'
7-
}
8-
};
9-
var out = sizlate.render(html, selectors);
10-
console.log(out);
5+
'div a': {
6+
className: 'class2'
7+
}
8+
}
9+
var out = sizlate.render(html, selectors)
10+
console.log(out)

examples/nested.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
var sizlate = require('sizlate');
1+
var sizlate = require('sizlate')
22

33
// currently only supports setting the innerHtml.
44

5-
var html = '<div><div id="one"><a href="sd"></a></div></div>';
5+
var html = '<div><div id="one"><a href="sd"></a></div></div>'
66
var selectors = {
7-
'#one': {
8-
selectors: {
9-
a: 'wotcha'
10-
}
7+
'#one': {
8+
selectors: {
9+
a: 'wotcha'
1110
}
12-
};
11+
}
12+
}
1313

14-
var out = sizlate.render(html, selectors);
15-
console.log(out);
14+
var out = sizlate.render(html, selectors)
15+
console.log(out)

examples/object.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
var sizlate = require('sizlate');
1+
var sizlate = require('sizlate')
22

3-
var html = '<div><a></a></div>';
3+
var html = '<div><a></a></div>'
44
var selectors = {
5-
'a': {
6-
href: 'http://yahoo.com',
7-
title: 'yahoo',
8-
innerHTML: 'yahoo'
9-
}
10-
};
11-
var out = sizlate.render(html, selectors);
12-
console.log(out);
5+
'a': {
6+
href: 'http://yahoo.com',
7+
title: 'yahoo',
8+
innerHTML: 'yahoo'
9+
}
10+
}
11+
var out = sizlate.render(html, selectors)
12+
console.log(out)

examples/regular-expression.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
var sizlate = require('sizlate');
1+
var sizlate = require('sizlate')
22

3-
var html = '<div><a>existing text</a></div>';
3+
var html = '<div><a>existing text</a></div>'
44
var selectors = {
5-
'a': {
6-
'innerText': {
7-
regex: /existing ([a-z]+)/ig,
8-
value: 'new $1'
9-
}
5+
'a': {
6+
'innerText': {
7+
regex: /existing ([a-z]+)/ig,
8+
value: 'new $1'
109
}
11-
};
12-
var out = sizlate.render(html, selectors);
13-
console.log(out);
10+
}
11+
}
12+
var out = sizlate.render(html, selectors)
13+
console.log(out)

examples/simple.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
var sizlate = require('sizlate');
2-
var out = sizlate.render('<div><a href=""></a></div>', {'div a': 'UPDATED'});
3-
console.log(out); // returns <div><a href="">UPDATED</a></div>
1+
var sizlate = require('sizlate')
2+
var out = sizlate.render('<div><a href=""></a></div>', { 'div a': 'UPDATED' })
3+
console.log(out) // returns <div><a href="">UPDATED</a></div>

lib/check-for-inputs.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44
* @param {String} data The value to be set on the html.
55
*/
66
module.exports = function ($node, data) {
7-
$node.each(function (i, elem) {
8-
var type = elem.tagName;
7+
$node.each(function (i, elem) {
8+
var type = elem.tagName
99

10-
if(this[i] && this[i].name) {
11-
type = this[i].name;
12-
}else {
13-
type = 'none';
14-
}
15-
if(type.toUpperCase() === 'INPUT') {
16-
$node.eq(i).attr('value', data);
17-
}else {
18-
$node.eq(i).html(data);
19-
}
20-
});
21-
return $node;
22-
};
10+
if (this[i] && this[i].name) {
11+
type = this[i].name
12+
} else {
13+
type = 'none'
14+
}
15+
if (type.toUpperCase() === 'INPUT') {
16+
$node.eq(i).attr('value', data)
17+
} else {
18+
$node.eq(i).html(data)
19+
}
20+
})
21+
return $node
22+
}

lib/classify-keys.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
'use strict';
1+
'use strict'
22

33
module.exports = function (data, options) {
4-
if (!options.classifyKeys || typeof data === 'undefined') {
5-
return data;
4+
if (!options.classifyKeys || typeof data === 'undefined') {
5+
return data
6+
}
7+
var c = data.length
8+
var retArray = []
9+
while (c--) {
10+
var newObj = {}
11+
for (var key in data[c]) {
12+
newObj['.' + key] = data[c][key]
613
}
7-
var c = data.length;
8-
var retArray = [];
9-
while (c--) {
10-
var newObj = {};
11-
for (var key in data[c]){
12-
newObj['.' + key] = data[c][key];
13-
}
14-
retArray.push(newObj);
15-
}
16-
return retArray;
17-
};
14+
retArray.push(newObj)
15+
}
16+
return retArray
17+
}

0 commit comments

Comments
 (0)