js2 0.3.17 → 0.3.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +5 -0
- data/lib/js2/browser.js +14 -5
- data/lib/js2/js2.js +19 -15
- metadata +2 -2
data/CHANGELOG
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
0.3.18
|
2
|
+
* COMMAND: updaters should be using targetDir instead of outDir
|
3
|
+
* JSML: fixed empty space problem
|
4
|
+
* JSML: support for self-closing tags: area, base, basefont, br, hr, input, img, link, meta
|
5
|
+
|
1
6
|
0.3.17
|
2
7
|
* CORE: Adding counter to foreach "foreach (var item:i in items) { }"
|
3
8
|
* COMMAND: Fixing compile to use targetDir instead of outDir
|
data/lib/js2/browser.js
CHANGED
@@ -19,7 +19,7 @@ function mainFunction (arg) {
|
|
19
19
|
|
20
20
|
var JS2 = root.JS2 = mainFunction;
|
21
21
|
var js2 = root.js2 = JS2;
|
22
|
-
js2.VERSION = "0.3.
|
22
|
+
js2.VERSION = "0.3.18";
|
23
23
|
|
24
24
|
JS2.ROOT = JS2;
|
25
25
|
|
@@ -269,7 +269,6 @@ JS2.Array.prototype.any = function() {
|
|
269
269
|
return this.length > 0;
|
270
270
|
};
|
271
271
|
|
272
|
-
|
273
272
|
JS2.Class.extend('JSML', function(KLASS, OO){
|
274
273
|
OO.addStaticMember("process",function (txt) {
|
275
274
|
return new KLASS(txt);
|
@@ -299,6 +298,8 @@ JS2.Array.prototype.any = function() {
|
|
299
298
|
});
|
300
299
|
|
301
300
|
OO.addMember("processLine",function (line) {
|
301
|
+
if (line.match(/^\s*$/)) return;
|
302
|
+
|
302
303
|
var ele = new JS2.JSMLElement(line);
|
303
304
|
var scope = this.getScope();
|
304
305
|
|
@@ -336,6 +337,7 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
|
|
336
337
|
OO.addMember("TOKEN_REGEX",/(\%|\#|\.)([\w][\w\-]*)/g);
|
337
338
|
OO.addMember("JS_REGEX",/^(-|=)(.*)$/g);
|
338
339
|
OO.addMember("SCOPE_OFFSET",1);
|
340
|
+
OO.addMember("SELF_CLOSING",{ area: null, basefont: null, br: null, hr: null, input: null, img: null, link: null, meta: null });
|
339
341
|
|
340
342
|
OO.addMember("initialize",function (line) {
|
341
343
|
this.children = [];
|
@@ -395,6 +397,12 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
|
|
395
397
|
if (!this.nodeType && (this.classes.length || this.nodeID)) {
|
396
398
|
this.nodeType = 'div';
|
397
399
|
}
|
400
|
+
|
401
|
+
if (this.SELF_CLOSING.hasOwnProperty(this.nodeType) && this.children.length == 0) {
|
402
|
+
this.selfClose = '/';
|
403
|
+
} else {
|
404
|
+
this.selfClose = '';
|
405
|
+
}
|
398
406
|
});
|
399
407
|
|
400
408
|
OO.addMember("flatten",function () {
|
@@ -410,8 +418,10 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
|
|
410
418
|
if (this.nodeType) {
|
411
419
|
this.handleJsEQ(out);
|
412
420
|
this.handleContent(out);
|
413
|
-
out.unshift('out.push("<' + this.nodeType + '"+JS2.JSMLElement.parseAttributes(' + (this.attributes || "{}") + ', ' + JSON.stringify(this.classes || []) + ', ' + JSON.stringify(this.id || null) + ')+">");\n');
|
414
|
-
|
421
|
+
out.unshift('out.push("<' + this.nodeType + '"+JS2.JSMLElement.parseAttributes(' + (this.attributes || "{}") + ', ' + JSON.stringify(this.classes || []) + ', ' + JSON.stringify(this.id || null) + ')+"' + this.selfClose + '>");\n');
|
422
|
+
if (this.selfClose == '') {
|
423
|
+
out.push('out.push(' + JSON.stringify("</"+(this.nodeType)+">") + ');\n');
|
424
|
+
}
|
415
425
|
} else {
|
416
426
|
this.handleJsExec(out);
|
417
427
|
this.handleJsEQ(out);
|
@@ -459,7 +469,6 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
|
|
459
469
|
});
|
460
470
|
});
|
461
471
|
|
462
|
-
|
463
472
|
JS2.TEMPLATES = { jsml: JS2.JSML };
|
464
473
|
|
465
474
|
|
data/lib/js2/js2.js
CHANGED
@@ -14,7 +14,7 @@ function mainFunction (arg) {
|
|
14
14
|
|
15
15
|
var JS2 = root.JS2 = mainFunction;
|
16
16
|
var js2 = root.js2 = JS2;
|
17
|
-
js2.VERSION = "0.3.
|
17
|
+
js2.VERSION = "0.3.18";
|
18
18
|
|
19
19
|
JS2.ROOT = JS2;
|
20
20
|
|
@@ -1124,7 +1124,6 @@ JS2.Array.prototype.any = function() {
|
|
1124
1124
|
return this.length > 0;
|
1125
1125
|
};
|
1126
1126
|
|
1127
|
-
|
1128
1127
|
JS2.Class.extend('FileSystem', function(KLASS, OO){
|
1129
1128
|
OO.addMember("initialize",function (adapter) {
|
1130
1129
|
this.adapter = adapter;
|
@@ -1234,13 +1233,12 @@ JS2.Class.extend('FileSystem', function(KLASS, OO){
|
|
1234
1233
|
});
|
1235
1234
|
});
|
1236
1235
|
|
1237
|
-
|
1238
1236
|
JS2.Class.extend('Updater', function(KLASS, OO){
|
1239
1237
|
OO.addMember("initialize",function (fs, inDir, outDir, recursive) {
|
1240
1238
|
this.recursive = recursive;
|
1241
|
-
this.fs
|
1242
|
-
this.inDir
|
1243
|
-
this.
|
1239
|
+
this.fs = fs;
|
1240
|
+
this.inDir = this.fs.canonical(inDir);
|
1241
|
+
this.targetDir = this.fs.canonical(outDir);
|
1244
1242
|
this.verbose = true;
|
1245
1243
|
});
|
1246
1244
|
|
@@ -1257,14 +1255,14 @@ JS2.Class.extend('Updater', function(KLASS, OO){
|
|
1257
1255
|
for(var _i1=0,_c1=subs,_l1=_c1.length,sub;(sub=_c1[_i1])||(_i1<_l1);_i1++){
|
1258
1256
|
var path = dir + '/' + sub;
|
1259
1257
|
if (this.fs.isDirectory(path)) {
|
1260
|
-
this.fs.mkdir(path.replace(this.inDir, this.
|
1258
|
+
this.fs.mkdir(path.replace(this.inDir, this.targetDir));
|
1261
1259
|
this.matchDirs(path);
|
1262
1260
|
}
|
1263
1261
|
}
|
1264
1262
|
});
|
1265
1263
|
|
1266
1264
|
OO.addMember("tryUpdate",function (file, force, funct) {
|
1267
|
-
var outFile = file.replace(this.inDir, this.
|
1265
|
+
var outFile = file.replace(this.inDir, this.targetDir).replace(/\.js2$/, '.js');
|
1268
1266
|
|
1269
1267
|
var dir = this.fs.dirname(file);
|
1270
1268
|
if (! this.fs.isDirectory(dir)) this.fs.mkpath(dir);
|
@@ -1280,7 +1278,6 @@ JS2.Class.extend('Updater', function(KLASS, OO){
|
|
1280
1278
|
});
|
1281
1279
|
});
|
1282
1280
|
|
1283
|
-
|
1284
1281
|
JS2.Class.extend('Config', function(KLASS, OO){
|
1285
1282
|
OO.addMember("CLI_REGEX",/^-(r|i|f|n|v|m)(=(\w+))?$/);
|
1286
1283
|
OO.addMember("optsLookup",{
|
@@ -1352,7 +1349,6 @@ JS2.Class.extend('Config', function(KLASS, OO){
|
|
1352
1349
|
|
1353
1350
|
});
|
1354
1351
|
|
1355
|
-
|
1356
1352
|
JS2.Class.extend('Commander', function(KLASS, OO){
|
1357
1353
|
OO.addMember("BANNER","js2 <command> [options] <arguments>\n" +
|
1358
1354
|
"VERSION: " + JS2.VERSION + "\n" +
|
@@ -1439,7 +1435,6 @@ JS2.Class.extend('Commander', function(KLASS, OO){
|
|
1439
1435
|
});
|
1440
1436
|
|
1441
1437
|
|
1442
|
-
|
1443
1438
|
JS2.Class.extend('BrowserDecorator', function(KLASS, OO){
|
1444
1439
|
OO.addMember("file",function (code) {
|
1445
1440
|
return code;
|
@@ -1484,7 +1479,6 @@ JS2.Class.extend('RingoDecorator', function(KLASS, OO){
|
|
1484
1479
|
|
1485
1480
|
JS2.DECORATOR = JS2.DECORATOR || new JS2.BrowserDecorator();
|
1486
1481
|
|
1487
|
-
|
1488
1482
|
JS2.Class.extend('JSML', function(KLASS, OO){
|
1489
1483
|
OO.addStaticMember("process",function (txt) {
|
1490
1484
|
return new KLASS(txt);
|
@@ -1514,6 +1508,8 @@ JS2.Class.extend('JSML', function(KLASS, OO){
|
|
1514
1508
|
});
|
1515
1509
|
|
1516
1510
|
OO.addMember("processLine",function (line) {
|
1511
|
+
if (line.match(/^\s*$/)) return;
|
1512
|
+
|
1517
1513
|
var ele = new JS2.JSMLElement(line);
|
1518
1514
|
var scope = this.getScope();
|
1519
1515
|
|
@@ -1551,6 +1547,7 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
|
|
1551
1547
|
OO.addMember("TOKEN_REGEX",/(\%|\#|\.)([\w][\w\-]*)/g);
|
1552
1548
|
OO.addMember("JS_REGEX",/^(-|=)(.*)$/g);
|
1553
1549
|
OO.addMember("SCOPE_OFFSET",1);
|
1550
|
+
OO.addMember("SELF_CLOSING",{ area: null, basefont: null, br: null, hr: null, input: null, img: null, link: null, meta: null });
|
1554
1551
|
|
1555
1552
|
OO.addMember("initialize",function (line) {
|
1556
1553
|
this.children = [];
|
@@ -1610,6 +1607,12 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
|
|
1610
1607
|
if (!this.nodeType && (this.classes.length || this.nodeID)) {
|
1611
1608
|
this.nodeType = 'div';
|
1612
1609
|
}
|
1610
|
+
|
1611
|
+
if (this.SELF_CLOSING.hasOwnProperty(this.nodeType) && this.children.length == 0) {
|
1612
|
+
this.selfClose = '/';
|
1613
|
+
} else {
|
1614
|
+
this.selfClose = '';
|
1615
|
+
}
|
1613
1616
|
});
|
1614
1617
|
|
1615
1618
|
OO.addMember("flatten",function () {
|
@@ -1625,8 +1628,10 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
|
|
1625
1628
|
if (this.nodeType) {
|
1626
1629
|
this.handleJsEQ(out);
|
1627
1630
|
this.handleContent(out);
|
1628
|
-
out.unshift('out.push("<' + this.nodeType + '"+JS2.JSMLElement.parseAttributes(' + (this.attributes || "{}") + ', ' + JSON.stringify(this.classes || []) + ', ' + JSON.stringify(this.id || null) + ')+">");\n');
|
1629
|
-
|
1631
|
+
out.unshift('out.push("<' + this.nodeType + '"+JS2.JSMLElement.parseAttributes(' + (this.attributes || "{}") + ', ' + JSON.stringify(this.classes || []) + ', ' + JSON.stringify(this.id || null) + ')+"' + this.selfClose + '>");\n');
|
1632
|
+
if (this.selfClose == '') {
|
1633
|
+
out.push('out.push(' + JSON.stringify("</"+(this.nodeType)+">") + ');\n');
|
1634
|
+
}
|
1630
1635
|
} else {
|
1631
1636
|
this.handleJsExec(out);
|
1632
1637
|
this.handleJsEQ(out);
|
@@ -1673,7 +1678,6 @@ JS2.Class.extend('JSMLElement', function(KLASS, OO){
|
|
1673
1678
|
return (out.length ? ' ' : '') + out.join(' ');
|
1674
1679
|
});
|
1675
1680
|
});
|
1676
|
-
|
1677
1681
|
JS2.TEMPLATES = { jsml: JS2.JSML };
|
1678
1682
|
|
1679
1683
|
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: js2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.3.
|
5
|
+
version: 0.3.18
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Jeff Su
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-04-
|
13
|
+
date: 2011-04-16 00:00:00 +08:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|