Comparing version 1.7.6 to 1.8.0
{ | ||
"name": "remixml", | ||
"version": "1.7.6", | ||
"version": "1.8.0", | ||
"description": "XML/HTML-like macro language/template engine", | ||
@@ -5,0 +5,0 @@ "main": "remixml.js", |
441
remixml.js
@@ -8,27 +8,44 @@ // Remixml v1.4: XML/HTML-like macro language | ||
{ "use strict"; | ||
var al = /[&<]/, splc = /\s*,\s*/, fcache = {}, rcache = {}, | ||
ctn = "_contents", txta = newel("textarea"), diva = newel("div"), | ||
diacr = {}; | ||
var log = console.log, bref; // For preparse state, not re-entry-safe | ||
const /** Object */ al = /[&<]/, splc = /\s*,\s*/; | ||
const /** Object */ fcache = {}, rcache = {}, diacr = {}; | ||
const /** string */ ctn = "_contents"; | ||
const /** Node */ txta = newel("textarea"), diva = newel("div"); | ||
var log = console.log; | ||
function isstring(s) | ||
// For preparse state, not re-entry-safe | ||
var /** Object<string,Array> */ bref; | ||
function /** !boolean */ isstring(/** * */ s) | ||
{ return O.prototype.toString.call(s) === "[object String]"; } | ||
function eumap(s) | ||
function /** string */ eumap(/** !string */ s) | ||
{ return {"+":"%2B"," ":"+","?":"%3F","&":"%26","#":"%23"}[s]; } | ||
function udate(t) { return t.valueOf() - t.getTimezoneOffset * 60000; } | ||
function replelm(n, o) { return o.parentNode.replaceChild(n, o); } | ||
function gattr(n, k) { return n.getAttribute(k); } | ||
function /** !Node */ replelm(/** !Node */ n, /** !Node */ o) | ||
{ return o.parentNode.replaceChild(n, o); | ||
} | ||
function /** string */ gattr(/** !Node */ n, /** string */ k) | ||
{ return n.getAttribute(k); | ||
} | ||
function sattr(n, k, v) { n.setAttribute(k, v); } | ||
function newel(n) { return D.createElement(n); } | ||
function rattr(n, k) { n.removeAttribute(k); } | ||
function isa(s) { return Array.isArray(s); } | ||
function pad0(i, p) | ||
{ for (i < 0 && p--, i = i + ""; i.length < p; i = "0" + i) {} | ||
return i; | ||
function /** !Node */ newel(/** !string */ n) | ||
{ return D.createElement(n); | ||
} | ||
function strftime(fmt, d, lang) | ||
function rattr(/** !Node */ n, /** string */ k) { n.removeAttribute(k); } | ||
function /** !boolean */ isa(/** * */ s) { return Array.isArray(s); } | ||
function /** !string */ pad0(/** !number */ i, /** !number */ p) | ||
{ var /** !string */ ret; | ||
for (i < 0 && p--, ret = i + ""; ret.length < p; ret = "0" + ret) {} | ||
return ret; | ||
} | ||
function /** !string */ | ||
strftime(/** !string */ fmt, /** !Date|!string */ d, /** !string */ lang) | ||
{ var t, j1, ut; | ||
@@ -43,7 +60,7 @@ if (!(d instanceof Date)) | ||
y = d.getFullYear(), h = d.getHours(), h24 = 86400000; | ||
function ifm(t, f) | ||
function /** !string */ ifm(/** string= */ t, /** string= */ f) | ||
{ var o = {}; | ||
o[t || "weekday"] = f || "short"; | ||
return new Intl.DateTimeFormat(lang, o) | ||
.format(d); | ||
.format(/** @type {!Date|!number|undefined} */ (d)); | ||
} | ||
@@ -58,3 +75,3 @@ function thu() | ||
{ case "a": return ifm(); | ||
case "A": return ifm(0, "long"); | ||
case "A": return ifm(undefined, "long"); | ||
case "b": return ifm("month"); | ||
@@ -103,17 +120,17 @@ case "B": return ifm("month", "long"); | ||
function getdf(n) | ||
function /** !Node */ getdf(/** !Node */ n) | ||
{ if (n.nodeType == 11) | ||
return n; | ||
var k = D.createRange(); | ||
var /** Range */ k = D.createRange(); | ||
k.selectNodeContents(n); | ||
return k.extractContents(); | ||
return /** @type {!Node} */ (k.extractContents()); | ||
} | ||
function dfhtml(n) | ||
{ var k = newel("div"); k.appendChild(n); return k.innerHTML; } | ||
function /** !string */ dfhtml(/** !Node */ n) | ||
{ var /** Node */ k = newel("div"); k.appendChild(n); return k.innerHTML; } | ||
function dfnone(n) | ||
{ var j; | ||
function /** !string */ dfnone(/** Node|string */ n) | ||
{ var /** Node */ j; | ||
nostr: | ||
switch (n.nodeType) | ||
switch (/** @type {number|undefined} */ (n.nodeType)) | ||
{ case 11: | ||
@@ -131,8 +148,9 @@ switch (n.childNodes.length) | ||
case undefined: | ||
if ((j = n.indexOf("&")) < 0 || n.indexOf(";", j + 2) < 0) | ||
return n; | ||
let /** number */ i; | ||
if ((i = n.indexOf("&")) < 0 || n.indexOf(";", i + 2) < 0) | ||
return /** @type {string} */ (n); | ||
} | ||
j = txta; | ||
switch (n.nodeType) | ||
{ case 11: j.appendChild(n); n = j; | ||
switch (/** @type {number|undefined} */ (n.nodeType)) | ||
{ case 11: j.appendChild(/** @type {Node} */ (n)); n = j; | ||
default: n = n.innerHTML; | ||
@@ -142,25 +160,31 @@ case undefined:; | ||
j.innerHTML = n; n = j.value; j.textContent = ""; | ||
return n; | ||
return /** @type {string} */ (n); | ||
} | ||
function txt2node(t) | ||
{ return t.nodeType ? t : (diva.innerHTML = t, getdf(diva)); } | ||
function /** !Node */ txt2node(/** string|Node */ t) | ||
{ return t.nodeType ? /** @type {!Node} */ (t) | ||
: (diva.innerHTML = t, getdf(diva)); | ||
} | ||
W.sizeof = function(s) | ||
W.sizeof = function /** !number */ (/** * */ s) | ||
{ return Number(s) === s ? 1 | ||
: s ? s.nodeType ? dfnone(s).length : s.length || O.keys(s).length : 0; | ||
: s ? s.nodeType ? dfnone(/** @type {!Node|!string} */ (s)).length | ||
: s.length || O.keys(/** @type {!Object} */ (s)).length : 0; | ||
}; | ||
function fvar(s, $, val) | ||
{ var i, j; | ||
i = (s = s.split(/[.[\]]+/)).shift(); | ||
function /** * */ fvar(/** !string */ s, /** !Object */ $, /** *= */ val) | ||
{ var /** string */ i; | ||
var /** Object */ j; | ||
var /** Array<string> */ a; | ||
i = (a = s.split(/[.[\]]+/)).shift(); | ||
if (val === undefined) | ||
{ $ = $[i]; | ||
{ val = $[i]; | ||
do | ||
{ if (!$) | ||
{ if (!val) | ||
break; | ||
i = s.shift() + ""; | ||
$ = $.nodeType ? $ = i == ctn ? getdf($) : gattr($, i) : $[i]; | ||
} while (s.length); | ||
return $; | ||
i = a.shift() + ""; | ||
val = val.nodeType ? val = i == ctn | ||
? getdf(val) : gattr(val, i) : val[i]; | ||
} while (a.length); | ||
return val; | ||
} | ||
@@ -170,4 +194,4 @@ do | ||
$[i] = j = {}; | ||
$ = j; i = s.shift(); | ||
} while (s.length); | ||
$ = j; i = a.shift(); | ||
} while (a.length); | ||
if (val == null) | ||
@@ -179,3 +203,3 @@ delete $[i]; | ||
function encpath(s) | ||
function /** !string */ encpath(/** !string */ s) | ||
{ return s.toLowerCase() | ||
@@ -187,3 +211,3 @@ .replace(/[^\0-~]/g, function(a) { return diacr[a] || a; }) | ||
function sp(j, s) | ||
function /** !string */ sp(/** !string */ j, /** !string */ s) | ||
{ if (j[0] == "0") | ||
@@ -196,5 +220,7 @@ j[0] = s; | ||
function fmtf(k, s, d) | ||
{ var t = k.toLocaleString(s, | ||
{minimumFractionDigits: d, maximumFractionDigits: d}); | ||
function /** !string */ | ||
fmtf(/** !number */ k, /** !string */ s, /** !number */ d) | ||
{ var /** string */ t | ||
= /** @type {function(string=, Object=):string} */ (k.toLocaleString)(s, | ||
{"minimumFractionDigits": d, "maximumFractionDigits": d}); | ||
if (t == k) | ||
@@ -204,6 +230,6 @@ { s = ""; | ||
s = "-", k = -k; | ||
k = Math.round(k * Math.pow(10, d)) + ""; | ||
while (k.length <= d) | ||
k = "0" + k; | ||
d = k.length - d; t = s + k.substr(0, d) + "." + k.substr(d); | ||
t = Math.round(k * Math.pow(10, d)) + ""; | ||
while (t.length <= d) | ||
t = "0" + t; | ||
d = t.length - d; t = s + t.substr(0, d) + "." + t.substr(d); | ||
} | ||
@@ -213,4 +239,7 @@ return t; | ||
function fmtcur(k, lang, cur) | ||
{ var t = k.toLocaleString(lang, {style:"currency", currency:cur}); | ||
function /** !string */ | ||
fmtcur(/** !number */ k, /** !string */ lang, /** !string */ cur) | ||
{ var /** string */ t | ||
= /** @type {function(string=, Object=):string} */ (k.toLocaleString)(lang, | ||
{"style":"currency", "currency":cur}); | ||
if (t == k) | ||
@@ -223,6 +252,8 @@ t = ({"EUR":"\u20AC", "USD":"$", "CNY":"\u00A5"}[cur] || cur) | ||
function insert(j, quot, fmt, $) | ||
{ if ((j = fvar(j, $)) != null) | ||
function /** !string|!Array{string} */ insert(/** !string */ k, | ||
/** string */ quot, /** string */ fmt, /** !Object */ $) | ||
{ var /** * */ j; | ||
if ((j = fvar(k, $)) != null) | ||
{ if (j.nodeType) | ||
{ j = j.cloneNode(1); | ||
{ j = j.cloneNode(true); | ||
switch (quot) | ||
@@ -234,20 +265,28 @@ { case "none":case "":case "recurse":case "r": | ||
} | ||
} else if (-(-j) == j) | ||
j += ""; | ||
// FIXME Bug in the google-closure-compiler | ||
// with optimizationlevel ADVANCED. | ||
// It misparses -(-j) as --j, so the -(0-j) forces the | ||
// compiler to do the right thing. | ||
} else if (-(0- /** @type {string} */ (j)) == j) | ||
/** @type {number} */ (j) += ""; | ||
else if (typeof j == "function") | ||
j = j($["_"], $); | ||
if (fmt && isstring(j)) | ||
{ fmt = fmt.match( | ||
{ let /** Array<string> */ r = fmt.match( | ||
/^([-+0]+)?([1-9][0-9]*)?(?:\.([0-9]+))?(t([^%]*%.+)|[a-zA-Z]|[A-Z]{3})?$/); | ||
var p = fmt[3], lang = $["sys"] && $["sys"]["lang"] || undefined; | ||
switch (fmt[4]) | ||
var p = r[3], lang = $["sys"] && $["sys"]["lang"] || undefined; | ||
switch (r[4]) | ||
{ case "c": j = String.fromCharCode(+j); break; | ||
case "d": j = parseInt(j, 10).toLocaleString(); break; | ||
case "e": j = (+j).toExponential(p > "" ? p : null); break; | ||
case "e": | ||
j = /** @type {function((null|string)):string} */ | ||
((+j).toExponential)(p > "" ? p : null); | ||
break; | ||
case "f": | ||
if (!(p > "")) | ||
p = 6; | ||
j = fmtf(+j, lang, p); | ||
j = fmtf(+j, lang, /** @type {number} */ (p)); | ||
break; | ||
case "g": j = (+j).toPrecision(p > "" ? p : 6); break; | ||
case "g": j = /** @type {function((number|string)):string} */ | ||
((+j).toPrecision)(p > "" ? p : 6); break; | ||
case "x": j = (parseInt(j, 10) >>> 0).toString(16); break; | ||
@@ -259,10 +298,12 @@ case "s": | ||
default: | ||
j = fmt[4][0] == "t" ? strftime(fmt[5], j, lang) | ||
: /[A-Z]{3}/.test(fmt[4]) ? fmtcur(+j, lang, fmt[4]) : j; | ||
j = r[4][0] == "t" | ||
? strftime(r[5], /** @type {string} */ (j), lang) | ||
: /[A-Z]{3}/.test(r[4]) ? fmtcur(+j, lang, r[4]) : j; | ||
} | ||
if (fmt[1]) | ||
{ if (fmt[1].indexOf("0") >= 0 && (p = +fmt[2])) | ||
j = +j < 0 ? sp(pad0(-j, p), "-") : pad0(j, p); | ||
if (fmt[1].indexOf("+") >= 0 && +j >= 0) | ||
j = sp(j, "+"); | ||
if (r[1]) | ||
{ if (r[1].indexOf("0") >= 0 && (p = +r[2])) | ||
j = +j < 0 ? sp(pad0(- /** @type {number} */ (j), p), "-") | ||
: pad0(/** @type {number} */ (j), p); | ||
if (r[1].indexOf("+") >= 0 && +j >= 0) | ||
j = sp(/** @type {string} */ (j), "+"); | ||
} | ||
@@ -273,3 +314,3 @@ } | ||
case "uric": j = j.replace(/[+ ?&#]/g, eumap); break; | ||
case "path": j = encpath(j); break; | ||
case "path": j = encpath(/** @type {string} */ (j)); break; | ||
default: | ||
@@ -283,17 +324,23 @@ if (isstring(j)) | ||
$["_"]["_ok"] = 0, j = ""; | ||
return j; | ||
return /** @type {string} */ (j); | ||
} | ||
function replent(s, $) | ||
{ function r(s) | ||
{ var c, i, j; | ||
function /** !string|!Node|!Array<string> */ | ||
replent(/** !string */ s, /** !Object */ $) | ||
{ function /** !string|!Node|!Array<string> */ | ||
r(/** !string|!Node|!Array<string> */ s) | ||
{ var /** string */ c; | ||
var /** !string|!Node|!Array<string> */ j; | ||
var /** Array<string> */ i; | ||
if (s.nodeType) | ||
{ if (c = s.firstChild) | ||
{ do | ||
if ((i = r(c)) != c) | ||
if (i.nodeType) | ||
s.replaceChild(i, c = i.lastChild || c); | ||
{ let /** Node */ h; | ||
if (h = s.firstChild) | ||
{ let /** !string|!Node|!Array<string> */ k; | ||
do | ||
if ((k = r(h)) != h) | ||
if (k.nodeType) | ||
s.replaceChild(/** @type {Node} */ (k), h = k.lastChild || h); | ||
else | ||
c.nodeValue = i; | ||
while(c = c.nextChild); | ||
h.nodeValue = k; | ||
while(h = h.nextChild); | ||
return s; | ||
@@ -317,4 +364,4 @@ } | ||
{ if (!s.lastChild) | ||
s = txt2node(s); | ||
s.appendChild(j); j = ""; | ||
s = txt2node(/** @type {string} */ (s)); | ||
s.appendChild(/** @type {Node} */ (j)); j = ""; | ||
} else | ||
@@ -330,7 +377,6 @@ { if (!s) | ||
if (isa(s)) | ||
{ s.push(j); | ||
{ s.push(/** @type {string} */ (j)); | ||
if (c) | ||
s.push(j); | ||
} | ||
else if (j = j + c) | ||
s.push(/** @type {string} */ (j)); | ||
} else if (j = j + c) | ||
if (c = s.lastChild) | ||
@@ -356,3 +402,3 @@ if (c.nodeType == 3 && !al.test(j)) | ||
function jsfunc(j) | ||
function /** function(!Object):* */ jsfunc(/** !string */ j) | ||
{ var e; | ||
@@ -365,3 +411,3 @@ if (!(e = fcache[j])) | ||
function trim(s) | ||
function trim(/** !Node */ s) | ||
{ var n = s.firstChild, i; | ||
@@ -380,3 +426,3 @@ if (n) | ||
function btrim(e) | ||
function /** !Node */ btrim(/** !Node */ e) | ||
{ var k; | ||
@@ -391,3 +437,4 @@ e.normalize(); trim(e); | ||
function settag(tpl, $, name, scope, noparse, args) | ||
function settag(/** !Node */ tpl, /** !Object */ $, /** !string */ name, | ||
/** string= */ scope, /** boolean= */ noparse, /** string= */ args) | ||
{ $["_"]["_tag"][name.toUpperCase()] = [tpl, scope, noparse, | ||
@@ -398,6 +445,10 @@ (args ? args.split(splc) : []) | ||
function parse(n, $) | ||
{ var j, rt, cc = bref && {}, k, e, c, ca, x, i, res, mkm, sc, ord, to; | ||
function eparse(n) { var k; parse(k = getdf(n), $); return k; } | ||
function gatt(k) { return gattr(n, k); } | ||
function /** number|undefined */ parse(/** Node */ n, /** !Object */ $) | ||
{ var j, rt, cc = bref && {}, k, e, c, ca, x, i, res, mkm, sc, to; | ||
function /** !Node */ eparse(/** !Node */ n) | ||
{ var /** Node */ k; parse(k = getdf(n), $); return k; | ||
} | ||
function /** string */ gatt(/** !string */ k) | ||
{ return gattr(/** @type {!Node} */ (n), k); | ||
} | ||
function run(k) | ||
@@ -407,10 +458,12 @@ { try { return k($); } catch(x) { logerr(gatt("expr"), x); } | ||
function repltag(e) | ||
{ var j, t; | ||
{ var j; | ||
var /** Node */ t; | ||
if (j = e.lastChild) | ||
t = n, n = j, replelm(e, t); | ||
t = /** @type {!Node} */ (n), n = j, replelm(e, t); | ||
else if (j = e.nodeValue) | ||
replelm(e, n), n = e; | ||
replelm(e, /** @type {!Node} */ (n)), n = e; | ||
return !j; | ||
} | ||
function newctx(k, j, e) | ||
function /** Node */ | ||
newctx(/** !Array */ k, /** Object */ j, /** Node= */ e) | ||
{ var o$ = $, at, _, i, v, r; | ||
@@ -427,17 +480,22 @@ if (e) | ||
if (e) | ||
{ if (e.nodeType != 11) | ||
e = getdf(e); | ||
{ let /** Node|string */ cn; | ||
if (e.nodeType != 11) | ||
cn = getdf(e); | ||
else if (!e.childElementCount) | ||
switch (e.childNodes.length) | ||
{ case 0: | ||
e = ""; | ||
cn = ""; | ||
break; | ||
case 1: | ||
e = e.firstChild.nodeValue; | ||
cn = e.firstChild.nodeValue; | ||
break; | ||
default: | ||
cn = e; | ||
} | ||
_[ctn] = e; _["_restargs"] = r = {}; | ||
_[ctn] = cn; _["_restargs"] = r = {}; | ||
for (i = at.length; i--; ) | ||
{ v = _[e = at[i].name] = at[i].value; | ||
if (!k[3][e]) // args | ||
r[e] = v; | ||
{ let /** string */ ts; | ||
v = _[ts = at[i].name] = at[i].value; | ||
if (!k[3][ts]) // args | ||
r[ts] = v; | ||
} | ||
@@ -447,8 +505,8 @@ } | ||
O.assign(_, j); | ||
j = eparse((j = k[0]).nodeType ? j.cloneNode(1) : txt2node(j($))); | ||
j = eparse((j = k[0]).nodeType ? j.cloneNode(true) : txt2node(j($))); | ||
($ = o$)["_"] = o$["_"]; | ||
return j; | ||
} | ||
function pexpr(c) | ||
{ var j; | ||
function /** * */ pexpr(/** !Node=|!string= */ c) | ||
{ var /** string */ j; | ||
return (j = gatt("expr")) != null && (c || j) | ||
@@ -465,3 +523,3 @@ && jsfunc(!j && c ? dfnone(c) : "return(" + dfnone(j) + ");"); | ||
function ret(e) { return repltag(txt2node(e)); } | ||
function pret() { return repltag(eparse(n)); } | ||
function pret() { return repltag(eparse(/** @type {!Node} */ (n))); } | ||
function cp(x) { c && c.push(x); } | ||
@@ -472,3 +530,3 @@ function prat(j) | ||
{ if ((e = replent(s, $)).nodeType) | ||
e = dfnone(e); | ||
e = dfnone(/** @type {!Node|!string} */ (e)); | ||
else if (i.name == "::") | ||
@@ -485,3 +543,3 @@ { x = e; cp(j); | ||
{ var j; | ||
rattr(n, "::"); | ||
rattr(/** @type {!Node} */ (n), "::"); | ||
for (j in x) | ||
@@ -513,3 +571,3 @@ sattr(n, j, x[j]); | ||
if (ca = gatt(":c")) | ||
rattr(n, ":c"); | ||
rattr(/** @type {!Node} */ (n), ":c"); | ||
if (ca && isa(ca = JSON.parse(ca))) | ||
@@ -533,6 +591,7 @@ for (j in ca) | ||
if (e = gatt("var")||gatt("variable")) | ||
{ if (k = pexpr(n)) | ||
{ if (k = pexpr(/** @type {!Node} */ (n))) | ||
k = run(k); | ||
else | ||
switch ((k = eparse(n)).childNodes.length) | ||
switch ((k = eparse(/** @type {!Node} */ (n))) | ||
.childNodes.length) | ||
{ case 0: k = ""; | ||
@@ -555,6 +614,7 @@ break; | ||
{ x = gatt("split"); | ||
if (j = pregx()) | ||
k = dfnone(k), k = x != null ? k.split(j) : k.match(j); | ||
else if (x != null) | ||
k = dfnone(k).split(x); | ||
if (j = pregx()) { | ||
k = dfnone(/** @type {!Node|!string} */ (k)); | ||
k = x != null ? k.split(j) : k.match(j); | ||
} else if (x != null) | ||
k = dfnone(/** @type {!Node|!string} */ (k)).split(x); | ||
if ((j = gatt("join")) != null) | ||
@@ -566,4 +626,4 @@ k = k.join(j); | ||
} else if (e = gatt("tag")) | ||
settag(getdf(n), $, e, gatt("scope"), gatt("noparse") != null, | ||
gatt("args")); | ||
settag(getdf(/** @type {!Node} */ (n)), $, e, gatt("scope"), | ||
gatt("noparse") != null, gatt("args")); | ||
continue drop; | ||
@@ -598,9 +658,14 @@ case "UNSET": | ||
if (j = gatt("orderby")) | ||
{ ord = jsfunc("" + function desc(i) | ||
{ let /** function(!Object):* */ ord; | ||
ord = jsfunc("" + function desc(i) | ||
{ return -(-i) === i ? -i : [i, 1]; | ||
} + "return[" + j + "];"); | ||
try | ||
{ (to = O.keys(e)).sort(function(a, b) | ||
{ var x, y, i, n, ret, r; | ||
x = ord(e[a], $); y = ord(e[b], $); | ||
{ let old_ = $._; | ||
(to = O.keys(/** @type {!Object}:* */ (e))) | ||
.sort(function(a, b) | ||
{ var x, y, i, n, r; | ||
var /** !number */ ret; | ||
$._ = e[a]; x = ord($); | ||
$._ = e[b]; y = ord($); | ||
for (i = 0, n = x.length; i < n; i++) | ||
@@ -610,3 +675,4 @@ { r = 0; | ||
r = 1, x[i] = x[i][0], y[i] = y[i][0]; | ||
if (ret = x[i] > y[i] || -(x[i] != y[i])) | ||
if (ret = /** @type {!number} */ | ||
(x[i] > y[i] || -(x[i] != y[i]))) | ||
return r ? -ret : ret; | ||
@@ -616,2 +682,3 @@ } | ||
}); | ||
$._ = old_; | ||
} catch(x) { logerr(j, x); } | ||
@@ -624,4 +691,7 @@ while (i < to.length) | ||
} else | ||
{ to = +gatt("to"); ord = +gatt("step") || 1; | ||
for (j = +gatt("from"); ord > 0 ? j <= to : to <= j; j += ord) | ||
{ let /** !number */ step = +gatt("step") || 1; | ||
to = +gatt("to"); | ||
for (j = +gatt("from"); | ||
step > 0 ? j <= to : to <= j; | ||
j += step) | ||
forloop(); | ||
@@ -642,5 +712,5 @@ } | ||
if ((j = +gatt("offset")) || (k = gatt("limit")) != null) | ||
e = dfnone(e).substr(j, +k); | ||
e = dfnone(/** @type {string} */ (e)).substr(j, +k); | ||
if (isa(e) && (j = gatt("join")) != null) | ||
e = e.join(j); | ||
e = /** @type {Array<string>} */ (e).join(j); | ||
if (ret(e)) | ||
@@ -659,5 +729,7 @@ continue drop; | ||
try | ||
{ if (ret(dfnone(eparse(n)).replace((k = pregx()) | ||
{ if (ret(dfnone(eparse(/** @type {!Node} */ (n))) | ||
.replace((k = pregx()) | ||
? RegExp(k, (e = gatt("flags")) == null ? "g" : e) | ||
: gatt("from"), pexpr() || gatt("to")))) | ||
: gatt("from"), | ||
/** @type {string} */ (pexpr()) || gatt("to")))) | ||
continue drop; | ||
@@ -667,3 +739,3 @@ } catch(x) { logerr(gatt("expr"), x); } | ||
case "TRIM": | ||
if (repltag(btrim(eparse(n)))) | ||
if (repltag(btrim(eparse(/** @type {!Node} */ (n))))) | ||
continue drop; | ||
@@ -681,3 +753,4 @@ break; | ||
} | ||
e.normalize(); n.appendChild(e); replelm(n, k); | ||
e.normalize(); n.appendChild(e); | ||
replelm(/** @type {!Node} */ (n), k); | ||
break; | ||
@@ -687,3 +760,4 @@ case "SCRIPT": | ||
for (j = -1; ++j < e.length; sattr(n, e[j].name, e[j].value)) {} | ||
n.textContent = k.textContent; replelm(n, k); | ||
n.textContent = k.textContent; | ||
replelm(/** @type {!Node} */ (n), k); | ||
break; | ||
@@ -700,7 +774,7 @@ case "EVAL": | ||
case "NOPARSE": | ||
if (repltag(getdf(n))) | ||
if (repltag(getdf(/** @type {!Node} */ (n)))) | ||
continue drop; | ||
break; | ||
case "NOOUTPUT": | ||
eparse(n); | ||
eparse(/** @type {!Node} */ (n)); | ||
case "COMMENT": | ||
@@ -710,3 +784,3 @@ continue drop; | ||
if (k = $["_"]["_tag"][j]) | ||
{ if (repltag(newctx(k, 0, n))) | ||
{ if (repltag(newctx(k, null, n))) | ||
continue drop; | ||
@@ -746,3 +820,5 @@ } else if (n.firstElementChild) // Avoid unnecessary recursion | ||
if (e != n.nodeValue) | ||
n.nodeValue = n.realvalue = e, rt = 1; | ||
{ n.nodeValue = n.realvalue = /** @type {!string} */ (e); | ||
rt = 1; | ||
} | ||
} | ||
@@ -772,8 +848,8 @@ } | ||
} | ||
for (n in cc) | ||
bref[n].push(cc[n]); | ||
for (k in cc) | ||
bref[k].push(cc[k]); | ||
return 0; | ||
} | ||
function initctx($) | ||
function /** !Object */ initctx(/** !Object */ $) | ||
{ if (!$) | ||
@@ -795,5 +871,6 @@ $ = {}; | ||
if ("ab".substr(-1) != "b") | ||
(function(p, s) { | ||
s = p.substr; | ||
p.substr = function(a, n) | ||
(function(p) { | ||
let s = p.substr; | ||
p.substr = function /** string */ | ||
(/** number */ a, /** number= */ n) | ||
{ return s.call(this, a < 0 ? this.length + a : a, n); }; | ||
@@ -809,15 +886,19 @@ })(String.prototype); | ||
var g = | ||
{ "preparse": function(tpl, $) | ||
{ var c, i, k; | ||
{ "preparse": function /** !Node */ (/** !Node */ tpl, /** !Object */ $) | ||
{ var /** Node */ c; | ||
if (c = tpl) | ||
{ bref = [0]; c = c.querySelectorAll("*"); | ||
for (i = 0; i < c.length; i++) | ||
sattr((k = c[i]), ":c", i + 1), bref.push([k]); | ||
k = parse(c = tpl.cloneNode(1), initctx($)); | ||
while (i = bref.pop()) | ||
if (i[1]) | ||
sattr(i[0], ":c", JSON.stringify(i[1])); | ||
{ let /** !NodeList<!Element> */ a; | ||
let /** number */ i; | ||
let /** Array */ b; | ||
let k; | ||
bref = [0]; a = c.querySelectorAll("*"); | ||
for (i = 0; i < a.length; i++) | ||
sattr((k = a[i]), ":c", i + 1), bref.push([k]); | ||
k = parse(c = tpl.cloneNode(true), initctx($)); | ||
while (b = bref.pop()) | ||
if (b[1]) | ||
sattr(b[0], ":c", JSON.stringify(b[1])); | ||
else | ||
rattr(i[0], ":c"); | ||
bref = 0; | ||
rattr(b[0], ":c"); | ||
bref = null; | ||
if (k) | ||
@@ -831,3 +912,3 @@ if (tpl.nodeType == 1) | ||
}, | ||
"parse": function(tpl, $) | ||
"parse": function /** Node */ (/** string|Node */ tpl, /** !Object */ $) | ||
{ if (tpl) | ||
@@ -837,4 +918,8 @@ tpl = txt2node(tpl), parse(tpl, initctx($)); | ||
}, | ||
"parse2txt": function(tpl, $) { return dfnone(g.parse(tpl, $)); }, | ||
"parse_tagged": function(tpl, $) | ||
"parse2txt": | ||
function /** !string */ (/** string|Node */ tpl, /** !Object */ $) | ||
{ return dfnone(g.parse(tpl, $)); | ||
}, | ||
"parse_tagged": | ||
function /** !Node */ (/** string|Node */ tpl, /** !Object */ $) | ||
{ var i, j = (tpl = txt2node(tpl)).querySelectorAll("remixml"), k; | ||
@@ -846,9 +931,18 @@ $ = initctx($); | ||
}, | ||
"parse_document": function($) { return g.parse(D.head.parentNode, $); }, | ||
"set_tag": function(cb, $, name, scope, noparse, args) | ||
"parse_document": function(/** !Object */ $) | ||
{ return g.parse(D.head.parentNode, $); | ||
}, | ||
"set_tag": function(cb, /** !Object */ $, /** !string */ name, | ||
/** string= */ scope, /** boolean= */ noparse, /** string= */ args) | ||
{ settag(cb, initctx($), name, scope, noparse, args); | ||
}, | ||
"dom2txt": function(tpl) { return dfnone(tpl); }, | ||
"txt2dom": function(tpl) { return txt2node(tpl); }, | ||
"trim": function(tpl) { return btrim(txt2node(tpl)); }, | ||
"dom2txt": function /** string */ (/** string|Node */ tpl) | ||
{ return dfnone(tpl); | ||
}, | ||
"txt2dom": function /** !Node */ (/** string|Node */ tpl) | ||
{ return txt2node(tpl); | ||
}, | ||
"trim": function /** !Node */ (/** string|Node */ tpl) | ||
{ return btrim(txt2node(tpl)); | ||
}, | ||
"path_encode": encpath, | ||
@@ -858,4 +952,5 @@ "set_log_callback": function(cb) { log = cb; } | ||
(function(fm, i, j, p) | ||
{ for (i in fm) | ||
(function(fm) | ||
{ var i, j, p; | ||
for (i in fm) | ||
for (p = 0; j = fm[i].pop(); diacr[String.fromCharCode(p = p + j)] = i) | ||
@@ -862,0 +957,0 @@ if (j < 0) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
50319
904