Skip to content

Commit 78370f3

Browse files
committed
es6 fixes
1 parent 89cae95 commit 78370f3

File tree

5 files changed

+53
-50
lines changed

5 files changed

+53
-50
lines changed

package.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package.describe({
22
name: 'mwc:synthesis',
3-
version: '1.0.20',
3+
version: '1.0.21',
44
summary: 'Synthesis is meteor + polymer',
55
git: 'https://github.com/meteorwebcomponents/synthesis',
66
documentation: 'README.md'

plugin/synthesis.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@ Plugin.registerCompiler({
22
extensions: ['html'],
33
archMatching: 'web',
44
isTemplate: true
5-
}, function(){
5+
}, ()=>{
66
return new PolymerCachingHtmlCompiler("synthesis", parseHtml, handleTags);
77
});
88

99

10-
var parse5 = Npm.require('parse5');
11-
var fs = Npm.require('fs');
12-
var path = Npm.require('path');
13-
var Future = Npm.require('fibers/future');
14-
var _ = Npm.require('lodash');
10+
const parse5 = Npm.require('parse5');
11+
const fs = Npm.require('fs');
12+
const path = Npm.require('path');
13+
const Future = Npm.require('fibers/future');
14+
const _ = Npm.require('lodash');
1515

16-
var throwCompileError = TemplatingTools.throwCompileError;
16+
const throwCompileError = TemplatingTools.throwCompileError;
1717

1818
class PolymerCachingHtmlCompiler extends CachingHtmlCompiler {
1919

@@ -27,7 +27,7 @@ class PolymerCachingHtmlCompiler extends CachingHtmlCompiler {
2727

2828
compileOneFile(inputFile) {
2929
const contents = inputFile.getContentsAsString();
30-
var packagePrefix = '';
30+
let packagePrefix = '';
3131

3232
if (inputFile.getPackageName()) {
3333
packagePrefix += '/packages/' + inputFile.getPackageName() + '/';
@@ -42,7 +42,7 @@ class PolymerCachingHtmlCompiler extends CachingHtmlCompiler {
4242
sourceName: inputPath,
4343
contents: contents
4444
});
45-
var result = this.tagHandlerFunc(tags);
45+
const result = this.tagHandlerFunc(tags);
4646
return result;
4747
} catch (e) {
4848
if (e instanceof TemplatingTools.CompileError) {
@@ -59,10 +59,10 @@ class PolymerCachingHtmlCompiler extends CachingHtmlCompiler {
5959

6060
};
6161

62-
parseHtml = function(arg){
63-
var contents = arg.contents
64-
var parseOptions = {}
65-
var parsed = parse5.parse(contents);
62+
const parseHtml = (arg)=>{
63+
const contents = arg.contents
64+
const parseOptions = {}
65+
const parsed = parse5.parse(contents);
6666
const tag = {
6767
tagName: "template",
6868
attribs: {
@@ -74,8 +74,8 @@ parseHtml = function(arg){
7474
};
7575
return tag;
7676
}
77-
function handleTags(tags) {
78-
var handler = new dissectHtml();
77+
const handleTags = (tags)=> {
78+
const handler = new dissectHtml();
7979
handler.dissect(tags);
8080
return handler.dissected;
8181
}
@@ -95,14 +95,14 @@ class dissectHtml {
9595
this.sourceName = tag.sourceName;
9696
const self = this;
9797
const children = this.document.childNodes || [];
98-
for(i=0;i<children.length;i++){
98+
for(let i=0;i<children.length;i++){
9999
const child = children[i];
100100
switch(child.nodeName){
101101
case "#documentType":
102102
break;
103103
case "html":
104104
const _children = child.childNodes || [];
105-
for(_i=0;_i<_children.length;_i++){
105+
for(let _i=0;_i<_children.length;_i++){
106106
_child = _children[_i];
107107
switch(_child.nodeName){
108108
case "head":
@@ -115,7 +115,7 @@ class dissectHtml {
115115
}
116116
break;
117117
case "script":
118-
var result = self.processScripts(__child);
118+
const result = self.processScripts(__child);
119119
if(result){
120120
return result;
121121
}
@@ -180,7 +180,7 @@ class dissectHtml {
180180
}
181181
break;
182182
case "script":
183-
var result = self.processScripts(child);
183+
const result = self.processScripts(child);
184184
if(result){
185185
return result;
186186
}
@@ -228,7 +228,7 @@ class dissectHtml {
228228
return url.match(/^(\.\/|\.\.\/)/) ? url : './'+url;
229229
}
230230
processLinks(child){
231-
var self = this;
231+
const self = this;
232232
if(child.attrs){
233233
const supportedRels = ["import","stylesheet"];
234234
const ifImport = _.find(child.attrs, (v) => {

plugin/synthesizer.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
_synthesizer = function(settings){
2-
this.settings = settings;
3-
}
4-
_synthesizer.prototype.generateJS =function(html,toHead){
5-
toHead = !!toHead;
6-
const htmlStr = JSON.stringify(html);
7-
return `
8-
Synthesizer.render(${htmlStr},${toHead});
9-
`
10-
}
1+
class _synthesizer{
2+
constructor(settings){
3+
this.settings = settings;
4+
}
5+
generateJS(html,toHead){
6+
toHead = !!toHead;
7+
const htmlStr = JSON.stringify(html);
8+
return `
9+
Synthesizer.render(${htmlStr},${toHead});
10+
`
11+
}
1112

13+
}
1214
Synthesizer = new _synthesizer();

synthesizer-browser.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
_synthesizer = function(settings){
2-
this.settings = settings;
3-
}
4-
5-
_synthesizer.prototype.render = function (str,head) {
6-
var el = head ? document.head : document.body;
7-
var div = document.createElement('div');
1+
class _synthesizer {
2+
constructor(settings){
3+
this.settings = settings;
4+
}
5+
render(str,head) {
6+
const el = head ? document.head : document.body;
7+
const div = document.createElement('div');
88
div.innerHTML = str;
99
while (div.children.length > 0) {
1010
el.appendChild(div.children[0]);
1111
}
1212

13+
}
1314
}
14-
1515
Synthesizer = new _synthesizer();

synthesizer-cordova.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
_synthesizer = function(settings){
2-
this.settings = settings;
3-
}
4-
_synthesizer.prototype.render = function (str,head) {
1+
class _synthesizer{
2+
constructor(settings){
3+
this.settings = settings;
4+
}
5+
render(str,head) {
56
document.addEventListener("deviceready", function() {
6-
var el = head ? document.head : document.body;
7-
var div = document.createElement('div');
8-
div.innerHTML = str;
9-
while (div.children.length > 0) {
10-
el.appendChild(div.children[0]);
11-
}
7+
const el = head ? document.head : document.body;
8+
const div = document.createElement('div');
9+
div.innerHTML = str;
10+
while (div.children.length > 0) {
11+
el.appendChild(div.children[0]);
12+
}
1213
});
14+
}
1315
}
14-
1516
Synthesizer = new _synthesizer();

0 commit comments

Comments
 (0)