release: WRNexusJS 0.5.0
This commit is contained in:
@@ -170,6 +170,45 @@ export const REACTIVE_RUNTIME = String.raw`
|
||||
var start = 0;
|
||||
var depth = 0;
|
||||
var quote = "";
|
||||
|
||||
function continuesOnNextLine(index) {
|
||||
var previousIndex = index - 1;
|
||||
var nextIndex = index + 1;
|
||||
|
||||
while (
|
||||
previousIndex >= start &&
|
||||
/\s/.test(input[previousIndex])
|
||||
) {
|
||||
previousIndex--;
|
||||
}
|
||||
|
||||
while (
|
||||
nextIndex < input.length &&
|
||||
/\s/.test(input[nextIndex])
|
||||
) {
|
||||
nextIndex++;
|
||||
}
|
||||
|
||||
var previous =
|
||||
previousIndex >= start
|
||||
? input[previousIndex]
|
||||
: "";
|
||||
var next =
|
||||
nextIndex < input.length
|
||||
? input[nextIndex]
|
||||
: "";
|
||||
|
||||
// Newlines are formatting whitespace while either side is an
|
||||
// incomplete expression. This covers multiline assignments and
|
||||
// ternaries emitted by formatted .wrn component functions.
|
||||
return (
|
||||
/[=+\-*/%?:,.!&|<>]/.test(
|
||||
previous,
|
||||
) ||
|
||||
/[.?+:*/%&|<>=]/.test(next)
|
||||
);
|
||||
}
|
||||
|
||||
for (var i = 0; i < input.length; i++) {
|
||||
var ch = input[i];
|
||||
if (quote) {
|
||||
@@ -191,6 +230,13 @@ export const REACTIVE_RUNTIME = String.raw`
|
||||
) &&
|
||||
depth === 0
|
||||
) {
|
||||
if (
|
||||
ch !== ";" &&
|
||||
continuesOnNextLine(i)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var nextIndex = i + 1;
|
||||
|
||||
while (
|
||||
@@ -409,6 +455,19 @@ export const REACTIVE_RUNTIME = String.raw`
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
lowerName.startsWith("data-") ||
|
||||
lowerName.startsWith("aria-")
|
||||
) {
|
||||
if (value == null) {
|
||||
node.removeAttribute(name);
|
||||
} else {
|
||||
node.setAttribute(name, String(value));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (value === false || value == null) {
|
||||
node.removeAttribute(name);
|
||||
} else {
|
||||
@@ -646,6 +705,7 @@ export const REACTIVE_RUNTIME = String.raw`
|
||||
if (name === "console") return console;
|
||||
if (name === "Array") return Array;
|
||||
if (name === "Number") return Number;
|
||||
if (name === "String") return String;
|
||||
if (name === "Math") return Math;
|
||||
if (name === "JSON") return JSON;
|
||||
if (name === "Date") return Date;
|
||||
@@ -655,6 +715,8 @@ export const REACTIVE_RUNTIME = String.raw`
|
||||
if (name === "navigator") return window.navigator;
|
||||
if (name === "setTimeout") return window.setTimeout.bind(window);
|
||||
if (name === "clearTimeout") return window.clearTimeout.bind(window);
|
||||
if (name === "setInterval") return window.setInterval.bind(window);
|
||||
if (name === "clearInterval") return window.clearInterval.bind(window);
|
||||
if (name === "requestAnimationFrame") return window.requestAnimationFrame.bind(window);
|
||||
if (name === "cancelAnimationFrame") return window.cancelAnimationFrame.bind(window);
|
||||
return undefined;
|
||||
|
||||
Reference in New Issue
Block a user