Skip to content

Commit d5d682a

Browse files
committed
Remove commented out implementation
1 parent 7eae456 commit d5d682a

File tree

1 file changed

+0
-108
lines changed

1 file changed

+0
-108
lines changed

src/index.mjs

Lines changed: 0 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ function build(input) {
5353
function commit() {
5454
if (!inTag) {
5555
if (field || (buffer = buffer.trim())) {
56-
// if (field || buffer) {
5756
if (hasChildren++) out += ',';
5857
out += field || JSON.stringify(buffer);
5958
}
@@ -64,23 +63,16 @@ function build(input) {
6463
mode = MODE_WHITESPACE;
6564
}
6665
else if (mode === MODE_ATTRIBUTE || (mode === MODE_WHITESPACE && buffer === '...')) {
67-
// if (!propCount++) {
68-
// propsStart = out.length + 1;
69-
// }
7066
if (mode === MODE_WHITESPACE) {
7167
spread = true;
7268
if (!spreads++) {
7369
if (propCount === 0) out += ',Object.assign({},';
7470
else out = out.replace(/,\(\{(.*?)$/, ',Object.assign({},{$1') + '},';
75-
// out = out.substring(0, propsStart) + out.substring;
7671
}
77-
// out += ',' + field;
7872
out += field + ',{';
7973
propCount++;
8074
}
81-
// out += ',';
8275
else if (propName) {
83-
// out += ',' + propName + ':';
8476
if (!spread) out += ',';
8577
if (propCount === 0) out += '({';
8678
out += propName + ':';
@@ -92,32 +84,23 @@ function build(input) {
9284
propHasValue = false;
9385
}
9486
else if (mode === MODE_WHITESPACE) {
95-
// if (buffer === '...') {
96-
// spread = true;
97-
// }
98-
// else {
99-
// spread = false;
10087
mode = MODE_ATTRIBUTE;
10188
// we're in an attribute name
10289
propName = buffer;
10390
buffer = field = '';
10491
commit();
10592
mode = MODE_WHITESPACE;
106-
// }
10793
}
10894
buffer = field = '';
109-
// hasChildren++;
11095
}
11196

11297
for (let i=0; i<input.length; i++) {
113-
// prevCharCode = charCode;
11498
charCode = input.charCodeAt(i);
11599
field = '';
116100

117101
if (charCode === QUOTE_SINGLE || charCode === QUOTE_DOUBLE) {
118102
if (quote === charCode) {
119103
quote = 0;
120-
// commit();
121104
continue;
122105
}
123106
if (quote === 0) {
@@ -127,7 +110,6 @@ function build(input) {
127110
}
128111

129112
if (charCode === 0) {
130-
// if (mode !== MODE_TAGNAME && mode !== MODE_ATTRIBUTE) commit();
131113
if (!inTag) commit();
132114
field = `$_h[${fieldIndex++}]`;
133115
commit();
@@ -144,18 +126,13 @@ function build(input) {
144126
propCount = 0;
145127
slash = spread = propHasValue = false;
146128
mode = MODE_TAGNAME;
147-
//if (buffer = buffer.trim()) out += JSON.stringify(buffer);
148-
// if (hasChildren++) out += ',';
149-
// out += 'h(';
150-
// buffer = '';
151129
continue;
152130
}
153131

154132
case TAG_END:
155133
if (inTag) {
156134
commit();
157135
if (mode !== MODE_SKIP) {
158-
// if (prevCharCode === SLASH) {
159136
if (propCount === 0) {
160137
out += ',null';
161138
}
@@ -164,24 +141,13 @@ function build(input) {
164141
}
165142
}
166143
if (slash) {
167-
// tags.pop();
168144
out += ')';
169145
}
170146
inTag = false;
171147
propCount = 0;
172148
mode = MODE_TEXT;
173149
continue;
174150
}
175-
176-
// case QUOTE_SINGLE:
177-
// case QUOTE_DOUBLE:
178-
// if (quote === charCode) {
179-
// quote = 0;
180-
// }
181-
// if (quote === 0) {
182-
// quote = charCode;
183-
// }
184-
// continue;
185151

186152
case EQUALS:
187153
if (inTag) {
@@ -197,7 +163,6 @@ function build(input) {
197163
if (!slash) {
198164
slash = true;
199165
// </foo>
200-
// console.log(mode === MODE_TAGNAME, field, buffer.trim());
201166
if (mode === MODE_TAGNAME && !field && !buffer.trim().length) {
202167
buffer = field = '';
203168
mode = MODE_SKIP;
@@ -214,85 +179,12 @@ function build(input) {
214179
commit();
215180
continue;
216181
}
217-
// else if (!buffer.length) continue;
218-
// commit = inTag === true;
219-
// continue;
220182
}
221183
}
222184

223185
buffer += input.charAt(i);
224186

225-
// // while ((token = TOKENIZER.exec(statics[i])) || ((field=`$_h[${i}]`), (buffer=''), (lastIndex=0), statics[++i])) {
226-
// // if (char==='\\' || !token) continue;
227-
// if (token[3] != null) break;
228-
// if (!token) {
229-
// if (!inTag) {
230-
// if (buffer) out += JSON.stringify(buffer);
231-
// out += field;
232-
// buffer = '';
233-
// field = null;
234-
// }
235-
// continue;
236-
// }
237-
// buffer += token.input.substring(lastIndex, token.index);
238-
// char = token[0];
239-
// if (!inTag) continue;
240-
// if (prev==='\\') out += prev + char;
241-
// else if (token[1] && !inQuote) inQuote = true;
242-
// else if (inQuote) {
243-
// if (inQuote===token[1]) {
244-
// inQuote = false;
245-
// quotedValue = field || JSON.stringify(buffer);
246-
// }
247-
// }
248-
// else if (char==='<') inTag = true;
249-
// else if (char==='>') inTag = false;
250-
// else if (char==='/' && prev==='<') out += ')';
251-
// else if (char==='=') {
252-
// propName = buffer;
253-
// // out += ',' + JSON.stringify(buffer) + ':';
254-
// }
255-
// else if (token[2]) {
256-
// if (prev==='<') {
257-
// const tag = field || JSON.stringify(buffer);
258-
// tags.push(tag);
259-
// if (buffer) {
260-
// out += JSON.stringify(buffer);
261-
// }
262-
// if (hasChildren) out += ',';
263-
// out += `h(${tag}`;
264-
// buffer = '';
265-
// hasChildren = true;
266-
// // childIndex = 0;
267-
// }
268-
// else {
269-
// out += ',' + JSON.stringify(propName || buffer) + ':' + (quotedValue || 'true');
270-
// buffer = propName = quotedValue = '';
271-
// }
272-
// }
273-
// prev = char;
274-
// field = null;
275-
// lastIndex = TOKENIZER.lastIndex;
276187
}
277188
commit();
278189
return Function('h', '$_h', out);
279-
// try {
280-
// return Function('h', '$_h', out);
281-
// }
282-
// catch (e) {
283-
// throw `input: ${out}\n${e}`;
284-
// }
285190
}
286-
287-
288-
/** Serialize a field to a String or reference for use in generated code. */
289-
// function field(value, sep) {
290-
// const matches = value.match(reg);
291-
// let strValue = JSON.stringify(value);
292-
// if (matches != null) {
293-
// if (matches[0] === value) return value;
294-
// strValue = strValue.replace(reg, `"${sep}$1${sep}"`).replace(/"[+,]"/g, '');
295-
// if (sep == ',') strValue = `[${strValue}]`;
296-
// }
297-
// return strValue;
298-
// }

0 commit comments

Comments
 (0)