mirror of
https://github.com/swc-project/swc.git
synced 2024-11-24 02:06:08 +03:00
fix(es/transforms/base): Optimize hygiene
(#2193)
swc_ecma_transforms_base: - `hygiene`: Don't rename if not required. (#1600) swc_ecma_minifier: - Remove `hygiene_optimizer`.
This commit is contained in:
parent
55f065b78a
commit
cb2b0c671f
8
Cargo.lock
generated
8
Cargo.lock
generated
@ -2287,7 +2287,7 @@ checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c"
|
||||
|
||||
[[package]]
|
||||
name = "swc"
|
||||
version = "0.48.0"
|
||||
version = "0.49.0"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"anyhow",
|
||||
@ -2628,7 +2628,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "swc_ecma_minifier"
|
||||
version = "0.24.0"
|
||||
version = "0.25.0"
|
||||
dependencies = [
|
||||
"ansi_term 0.12.1",
|
||||
"anyhow",
|
||||
@ -2737,7 +2737,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "swc_ecma_transforms_base"
|
||||
version = "0.30.0"
|
||||
version = "0.30.1"
|
||||
dependencies = [
|
||||
"fxhash",
|
||||
"once_cell",
|
||||
@ -2968,7 +2968,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "swc_ecmascript"
|
||||
version = "0.60.0"
|
||||
version = "0.61.0"
|
||||
dependencies = [
|
||||
"swc_ecma_ast",
|
||||
"swc_ecma_codegen",
|
||||
|
@ -20,7 +20,7 @@ edition = "2018"
|
||||
license = "Apache-2.0/MIT"
|
||||
name = "swc"
|
||||
repository = "https://github.com/swc-project/swc.git"
|
||||
version = "0.48.0"
|
||||
version = "0.49.0"
|
||||
|
||||
[lib]
|
||||
name = "swc"
|
||||
@ -52,7 +52,7 @@ swc_ecma_ast = {version = "0.51.1", path = "./ecmascript/ast"}
|
||||
swc_ecma_codegen = {version = "0.69.1", path = "./ecmascript/codegen"}
|
||||
swc_ecma_ext_transforms = {version = "0.27.1", path = "./ecmascript/ext-transforms"}
|
||||
swc_ecma_loader = {version = "0.17.1", path = "./ecmascript/loader", features = ["lru", "node", "tsc"]}
|
||||
swc_ecma_minifier = {version = "0.24.0", path = "./ecmascript/minifier"}
|
||||
swc_ecma_minifier = {version = "0.25.0", path = "./ecmascript/minifier"}
|
||||
swc_ecma_parser = {version = "0.69.1", path = "./ecmascript/parser"}
|
||||
swc_ecma_preset_env = {version = "0.40.0", path = "./ecmascript/preset-env"}
|
||||
swc_ecma_transforms = {version = "0.69.0", path = "./ecmascript/transforms", features = [
|
||||
@ -66,7 +66,7 @@ swc_ecma_transforms = {version = "0.69.0", path = "./ecmascript/transforms", fea
|
||||
swc_ecma_transforms_base = {version = "0.30.0", path = "./ecmascript/transforms/base"}
|
||||
swc_ecma_utils = {version = "0.43.1", path = "./ecmascript/utils"}
|
||||
swc_ecma_visit = {version = "0.37.1", path = "./ecmascript/visit"}
|
||||
swc_ecmascript = {version = "0.60.0", path = "./ecmascript"}
|
||||
swc_ecmascript = {version = "0.61.0", path = "./ecmascript"}
|
||||
swc_node_base = {version = "0.2.3", path = "./node/base"}
|
||||
swc_visit = {version = "0.2.3", path = "./visit"}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
let badfunc = ()=>{
|
||||
};
|
||||
function f1() {
|
||||
badfunc = function badfunc1() {
|
||||
badfunc = function badfunc() {
|
||||
};
|
||||
badfunc();
|
||||
f2();
|
||||
|
@ -1,7 +1,7 @@
|
||||
let badfunc = ()=>{
|
||||
};
|
||||
function f1() {
|
||||
badfunc = function badfunc1() {
|
||||
badfunc = function badfunc() {
|
||||
};
|
||||
badfunc();
|
||||
f2();
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,9 +1,9 @@
|
||||
var Bar1;
|
||||
(function(Bar1) {
|
||||
(function(Bar) {
|
||||
function foo() {
|
||||
console.log("foo");
|
||||
}
|
||||
Bar1.foo = foo;
|
||||
Bar.foo = foo;
|
||||
})(Bar1 || (Bar1 = {
|
||||
}));
|
||||
export { Bar1 as Bar };
|
||||
|
@ -1,9 +1,9 @@
|
||||
var Bar1;
|
||||
(function(Bar1) {
|
||||
(function(Bar) {
|
||||
function foo() {
|
||||
console.log("foo");
|
||||
}
|
||||
Bar1.foo = foo;
|
||||
Bar.foo = foo;
|
||||
})(Bar1 || (Bar1 = {
|
||||
}));
|
||||
export { Bar1 as Bar };
|
||||
|
@ -703,8 +703,8 @@ function fetchWrapper(requestOptions) {
|
||||
});
|
||||
}
|
||||
if (status >= 400) {
|
||||
return response.text().then((message2)=>{
|
||||
const error = new RequestError(message2, status, {
|
||||
return response.text().then((message)=>{
|
||||
const error = new RequestError(message, status, {
|
||||
headers,
|
||||
request: requestOptions
|
||||
});
|
||||
|
@ -703,8 +703,8 @@ function fetchWrapper(requestOptions) {
|
||||
});
|
||||
}
|
||||
if (status >= 400) {
|
||||
return response.text().then((message2)=>{
|
||||
const error = new RequestError(message2, status, {
|
||||
return response.text().then((message)=>{
|
||||
const error = new RequestError(message, status, {
|
||||
headers,
|
||||
request: requestOptions
|
||||
});
|
||||
|
@ -3,17 +3,17 @@ if (!m) {
|
||||
throw new Error('b');
|
||||
}
|
||||
class Comparator1 {
|
||||
constructor(comp1, optionsOrLoose = {
|
||||
constructor(comp, optionsOrLoose = {
|
||||
}){
|
||||
}
|
||||
parse(comp) {
|
||||
const m1 = "another";
|
||||
if (!m1) {
|
||||
const m = "another";
|
||||
if (!m) {
|
||||
throw new TypeError("Invalid comparator: " + comp);
|
||||
}
|
||||
const m11 = m1[1];
|
||||
console.log(m11);
|
||||
if (!m1[2]) {
|
||||
const m1 = m[1];
|
||||
console.log(m1);
|
||||
if (!m[2]) {
|
||||
console.log('other');
|
||||
}
|
||||
}
|
||||
|
@ -3,17 +3,17 @@ if (!m) {
|
||||
throw new Error('b');
|
||||
}
|
||||
class Comparator1 {
|
||||
constructor(comp1, optionsOrLoose = {
|
||||
constructor(comp, optionsOrLoose = {
|
||||
}){
|
||||
}
|
||||
parse(comp) {
|
||||
const m1 = "another";
|
||||
if (!m1) {
|
||||
const m = "another";
|
||||
if (!m) {
|
||||
throw new TypeError("Invalid comparator: " + comp);
|
||||
}
|
||||
const m11 = m1[1];
|
||||
console.log(m11);
|
||||
if (!m1[2]) {
|
||||
const m1 = m[1];
|
||||
console.log(m1);
|
||||
if (!m[2]) {
|
||||
console.log('other');
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -84,9 +84,9 @@ function parse(args, { "--": doubleDash = false , alias ={
|
||||
] : string;
|
||||
for (const key of stringArgs.filter(Boolean)){
|
||||
flags.strings[key] = true;
|
||||
const alias1 = get(aliases, key);
|
||||
if (alias1) {
|
||||
for (const al of alias1){
|
||||
const alias = get(aliases, key);
|
||||
if (alias) {
|
||||
for (const al of alias){
|
||||
flags.strings[al] = true;
|
||||
}
|
||||
}
|
||||
@ -125,9 +125,9 @@ function parse(args, { "--": doubleDash = false , alias ={
|
||||
}
|
||||
const value = !get(flags.strings, key) && isNumber(val) ? Number(val) : val;
|
||||
setKey(argv, key.split("."), value);
|
||||
const alias1 = get(aliases, key);
|
||||
if (alias1) {
|
||||
for (const x of alias1){
|
||||
const alias = get(aliases, key);
|
||||
if (alias) {
|
||||
for (const x of alias){
|
||||
setKey(argv, x.split("."), value);
|
||||
}
|
||||
}
|
||||
@ -149,12 +149,12 @@ function parse(args, { "--": doubleDash = false , alias ={
|
||||
if (/^--.+=/.test(arg)) {
|
||||
const m = arg.match(/^--([^=]+)=(.*)$/s);
|
||||
assert(m != null);
|
||||
const [, key1, value] = m;
|
||||
if (flags.bools[key1]) {
|
||||
const [, key, value] = m;
|
||||
if (flags.bools[key]) {
|
||||
const booleanValue = value !== "false";
|
||||
setArg(key1, booleanValue, arg);
|
||||
setArg(key, booleanValue, arg);
|
||||
} else {
|
||||
setArg(key1, value, arg);
|
||||
setArg(key, value, arg);
|
||||
}
|
||||
} else if (/^--no-.+/.test(arg)) {
|
||||
const m = arg.match(/^--no-(.+)/);
|
||||
@ -163,16 +163,16 @@ function parse(args, { "--": doubleDash = false , alias ={
|
||||
} else if (/^--.+/.test(arg)) {
|
||||
const m = arg.match(/^--(.+)/);
|
||||
assert(m != null);
|
||||
const [, key1] = m;
|
||||
const [, key] = m;
|
||||
const next = args[i + 1];
|
||||
if (next !== undefined && !/^-/.test(next) && !get(flags.bools, key1) && !flags.allBools && (get(aliases, key1) ? !aliasIsBoolean(key1) : true)) {
|
||||
setArg(key1, next, arg);
|
||||
if (next !== undefined && !/^-/.test(next) && !get(flags.bools, key) && !flags.allBools && (get(aliases, key) ? !aliasIsBoolean(key) : true)) {
|
||||
setArg(key, next, arg);
|
||||
i++;
|
||||
} else if (/^(true|false)$/.test(next)) {
|
||||
setArg(key1, next === "true", arg);
|
||||
setArg(key, next === "true", arg);
|
||||
i++;
|
||||
} else {
|
||||
setArg(key1, get(flags.strings, key1) ? "" : true, arg);
|
||||
setArg(key, get(flags.strings, key) ? "" : true, arg);
|
||||
}
|
||||
} else if (/^-[^-]+/.test(arg)) {
|
||||
const letters = arg.slice(1, -1).split("");
|
||||
@ -201,16 +201,16 @@ function parse(args, { "--": doubleDash = false , alias ={
|
||||
setArg(letters[j], get(flags.strings, letters[j]) ? "" : true, arg);
|
||||
}
|
||||
}
|
||||
const [key1] = arg.slice(-1);
|
||||
if (!broken && key1 !== "-") {
|
||||
if (args[i + 1] && !/^(-|--)[^-]/.test(args[i + 1]) && !get(flags.bools, key1) && (get(aliases, key1) ? !aliasIsBoolean(key1) : true)) {
|
||||
setArg(key1, args[i + 1], arg);
|
||||
const [key] = arg.slice(-1);
|
||||
if (!broken && key !== "-") {
|
||||
if (args[i + 1] && !/^(-|--)[^-]/.test(args[i + 1]) && !get(flags.bools, key) && (get(aliases, key) ? !aliasIsBoolean(key) : true)) {
|
||||
setArg(key, args[i + 1], arg);
|
||||
i++;
|
||||
} else if (args[i + 1] && /^(true|false)$/.test(args[i + 1])) {
|
||||
setArg(key1, args[i + 1] === "true", arg);
|
||||
setArg(key, args[i + 1] === "true", arg);
|
||||
i++;
|
||||
} else {
|
||||
setArg(key1, get(flags.strings, key1) ? "" : true, arg);
|
||||
setArg(key, get(flags.strings, key) ? "" : true, arg);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -235,12 +235,12 @@ function parse(args, { "--": doubleDash = false , alias ={
|
||||
}
|
||||
if (doubleDash) {
|
||||
argv["--"] = [];
|
||||
for (const key2 of notFlags){
|
||||
argv["--"].push(key2);
|
||||
for (const key of notFlags){
|
||||
argv["--"].push(key);
|
||||
}
|
||||
} else {
|
||||
for (const key2 of notFlags){
|
||||
argv._.push(key2);
|
||||
for (const key of notFlags){
|
||||
argv._.push(key);
|
||||
}
|
||||
}
|
||||
return argv;
|
||||
|
@ -84,9 +84,9 @@ function parse(args, { "--": doubleDash = false , alias ={
|
||||
] : string;
|
||||
for (const key of stringArgs.filter(Boolean)){
|
||||
flags.strings[key] = true;
|
||||
const alias1 = get(aliases, key);
|
||||
if (alias1) {
|
||||
for (const al of alias1){
|
||||
const alias = get(aliases, key);
|
||||
if (alias) {
|
||||
for (const al of alias){
|
||||
flags.strings[al] = true;
|
||||
}
|
||||
}
|
||||
@ -125,9 +125,9 @@ function parse(args, { "--": doubleDash = false , alias ={
|
||||
}
|
||||
const value = !get(flags.strings, key) && isNumber(val) ? Number(val) : val;
|
||||
setKey(argv, key.split("."), value);
|
||||
const alias1 = get(aliases, key);
|
||||
if (alias1) {
|
||||
for (const x of alias1){
|
||||
const alias = get(aliases, key);
|
||||
if (alias) {
|
||||
for (const x of alias){
|
||||
setKey(argv, x.split("."), value);
|
||||
}
|
||||
}
|
||||
@ -149,12 +149,12 @@ function parse(args, { "--": doubleDash = false , alias ={
|
||||
if (/^--.+=/.test(arg)) {
|
||||
const m = arg.match(/^--([^=]+)=(.*)$/s);
|
||||
assert(m != null);
|
||||
const [, key1, value] = m;
|
||||
if (flags.bools[key1]) {
|
||||
const [, key, value] = m;
|
||||
if (flags.bools[key]) {
|
||||
const booleanValue = value !== "false";
|
||||
setArg(key1, booleanValue, arg);
|
||||
setArg(key, booleanValue, arg);
|
||||
} else {
|
||||
setArg(key1, value, arg);
|
||||
setArg(key, value, arg);
|
||||
}
|
||||
} else if (/^--no-.+/.test(arg)) {
|
||||
const m = arg.match(/^--no-(.+)/);
|
||||
@ -163,16 +163,16 @@ function parse(args, { "--": doubleDash = false , alias ={
|
||||
} else if (/^--.+/.test(arg)) {
|
||||
const m = arg.match(/^--(.+)/);
|
||||
assert(m != null);
|
||||
const [, key1] = m;
|
||||
const [, key] = m;
|
||||
const next = args[i + 1];
|
||||
if (next !== undefined && !/^-/.test(next) && !get(flags.bools, key1) && !flags.allBools && (get(aliases, key1) ? !aliasIsBoolean(key1) : true)) {
|
||||
setArg(key1, next, arg);
|
||||
if (next !== undefined && !/^-/.test(next) && !get(flags.bools, key) && !flags.allBools && (get(aliases, key) ? !aliasIsBoolean(key) : true)) {
|
||||
setArg(key, next, arg);
|
||||
i++;
|
||||
} else if (/^(true|false)$/.test(next)) {
|
||||
setArg(key1, next === "true", arg);
|
||||
setArg(key, next === "true", arg);
|
||||
i++;
|
||||
} else {
|
||||
setArg(key1, get(flags.strings, key1) ? "" : true, arg);
|
||||
setArg(key, get(flags.strings, key) ? "" : true, arg);
|
||||
}
|
||||
} else if (/^-[^-]+/.test(arg)) {
|
||||
const letters = arg.slice(1, -1).split("");
|
||||
@ -201,16 +201,16 @@ function parse(args, { "--": doubleDash = false , alias ={
|
||||
setArg(letters[j], get(flags.strings, letters[j]) ? "" : true, arg);
|
||||
}
|
||||
}
|
||||
const [key1] = arg.slice(-1);
|
||||
if (!broken && key1 !== "-") {
|
||||
if (args[i + 1] && !/^(-|--)[^-]/.test(args[i + 1]) && !get(flags.bools, key1) && (get(aliases, key1) ? !aliasIsBoolean(key1) : true)) {
|
||||
setArg(key1, args[i + 1], arg);
|
||||
const [key] = arg.slice(-1);
|
||||
if (!broken && key !== "-") {
|
||||
if (args[i + 1] && !/^(-|--)[^-]/.test(args[i + 1]) && !get(flags.bools, key) && (get(aliases, key) ? !aliasIsBoolean(key) : true)) {
|
||||
setArg(key, args[i + 1], arg);
|
||||
i++;
|
||||
} else if (args[i + 1] && /^(true|false)$/.test(args[i + 1])) {
|
||||
setArg(key1, args[i + 1] === "true", arg);
|
||||
setArg(key, args[i + 1] === "true", arg);
|
||||
i++;
|
||||
} else {
|
||||
setArg(key1, get(flags.strings, key1) ? "" : true, arg);
|
||||
setArg(key, get(flags.strings, key) ? "" : true, arg);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -235,12 +235,12 @@ function parse(args, { "--": doubleDash = false , alias ={
|
||||
}
|
||||
if (doubleDash) {
|
||||
argv["--"] = [];
|
||||
for (const key2 of notFlags){
|
||||
argv["--"].push(key2);
|
||||
for (const key of notFlags){
|
||||
argv["--"].push(key);
|
||||
}
|
||||
} else {
|
||||
for (const key2 of notFlags){
|
||||
argv._.push(key2);
|
||||
for (const key of notFlags){
|
||||
argv._.push(key);
|
||||
}
|
||||
}
|
||||
return argv;
|
||||
|
@ -1,4 +1,4 @@
|
||||
class Image1 {
|
||||
class Image {
|
||||
getPixel(x, y) {
|
||||
const index = x + y * this.width;
|
||||
const rntVal = {
|
||||
@ -950,7 +950,7 @@ const decode1 = function(jpegData, colorTransform = true) {
|
||||
const decoder = new JpegImage();
|
||||
decoder.parse(arr);
|
||||
decoder.colorTransform = colorTransform;
|
||||
const image = new Image1();
|
||||
const image = new Image();
|
||||
image.height = decoder.height;
|
||||
image.width = decoder.width;
|
||||
image.data = new Uint8Array(decoder.width * decoder.height * 4);
|
||||
|
@ -1,4 +1,4 @@
|
||||
class Image1 {
|
||||
class Image {
|
||||
getPixel(x, y) {
|
||||
const index = x + y * this.width;
|
||||
const rntVal = {
|
||||
@ -950,7 +950,7 @@ const decode1 = function(jpegData, colorTransform = true) {
|
||||
const decoder = new JpegImage();
|
||||
decoder.parse(arr);
|
||||
decoder.colorTransform = colorTransform;
|
||||
const image = new Image1();
|
||||
const image = new Image();
|
||||
image.height = decoder.height;
|
||||
image.width = decoder.width;
|
||||
image.data = new Uint8Array(decoder.width * decoder.height * 4);
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -187,7 +187,7 @@ function isPathSeparator(code) {
|
||||
function isWindowsDeviceRoot(code) {
|
||||
return code >= 97 && code <= 122 || code >= 65 && code <= 90;
|
||||
}
|
||||
function normalizeString(path, allowAboveRoot, separator, isPathSeparator1) {
|
||||
function normalizeString(path, allowAboveRoot, separator, isPathSeparator) {
|
||||
let res = "";
|
||||
let lastSegmentLength = 0;
|
||||
let lastSlash = -1;
|
||||
@ -195,9 +195,9 @@ function normalizeString(path, allowAboveRoot, separator, isPathSeparator1) {
|
||||
let code;
|
||||
for(let i = 0, len = path.length; i <= len; ++i){
|
||||
if (i < len) code = path.charCodeAt(i);
|
||||
else if (isPathSeparator1(code)) break;
|
||||
else if (isPathSeparator(code)) break;
|
||||
else code = CHAR_FORWARD_SLASH;
|
||||
if (isPathSeparator1(code)) {
|
||||
if (isPathSeparator(code)) {
|
||||
if (lastSlash === i - 1 || dots === 1) {
|
||||
} else if (lastSlash !== i - 1 && dots === 2) {
|
||||
if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== 46 || res.charCodeAt(res.length - 2) !== 46) {
|
||||
@ -917,12 +917,12 @@ function resolve1(...pathSegments) {
|
||||
function normalize1(path) {
|
||||
assertPath(path);
|
||||
if (path.length === 0) return ".";
|
||||
const isAbsolute1 = path.charCodeAt(0) === 47;
|
||||
const isAbsolute = path.charCodeAt(0) === 47;
|
||||
const trailingSeparator = path.charCodeAt(path.length - 1) === 47;
|
||||
path = normalizeString(path, !isAbsolute1, "/", isPosixPathSeparator);
|
||||
if (path.length === 0 && !isAbsolute1) path = ".";
|
||||
path = normalizeString(path, !isAbsolute, "/", isPosixPathSeparator);
|
||||
if (path.length === 0 && !isAbsolute) path = ".";
|
||||
if (path.length > 0 && trailingSeparator) path += "/";
|
||||
if (isAbsolute1) return `/${path}`;
|
||||
if (isAbsolute) return `/${path}`;
|
||||
return path;
|
||||
}
|
||||
function isAbsolute1(path) {
|
||||
@ -1128,9 +1128,9 @@ function parse1(path) {
|
||||
name: ""
|
||||
};
|
||||
if (path.length === 0) return ret;
|
||||
const isAbsolute2 = path.charCodeAt(0) === 47;
|
||||
const isAbsolute = path.charCodeAt(0) === 47;
|
||||
let start;
|
||||
if (isAbsolute2) {
|
||||
if (isAbsolute) {
|
||||
ret.root = "/";
|
||||
start = 1;
|
||||
} else {
|
||||
@ -1164,14 +1164,14 @@ function parse1(path) {
|
||||
}
|
||||
if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
|
||||
if (end !== -1) {
|
||||
if (startPart === 0 && isAbsolute2) {
|
||||
if (startPart === 0 && isAbsolute) {
|
||||
ret.base = ret.name = path.slice(1, end);
|
||||
} else {
|
||||
ret.base = ret.name = path.slice(startPart, end);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (startPart === 0 && isAbsolute2) {
|
||||
if (startPart === 0 && isAbsolute) {
|
||||
ret.name = path.slice(1, startDot);
|
||||
ret.base = path.slice(1, end);
|
||||
} else {
|
||||
@ -1181,7 +1181,7 @@ function parse1(path) {
|
||||
ret.ext = path.slice(startDot, end);
|
||||
}
|
||||
if (startPart > 0) ret.dir = path.slice(0, startPart - 1);
|
||||
else if (isAbsolute2) ret.dir = "/";
|
||||
else if (isAbsolute) ret.dir = "/";
|
||||
return ret;
|
||||
}
|
||||
function fromFileUrl1(url) {
|
||||
@ -1241,14 +1241,14 @@ class BufReader {
|
||||
static create(r, size = 4096) {
|
||||
return r instanceof BufReader ? r : new BufReader(r, size);
|
||||
}
|
||||
constructor(rd1, size1 = 4096){
|
||||
constructor(rd, size = 4096){
|
||||
this.r = 0;
|
||||
this.w = 0;
|
||||
this.eof = false;
|
||||
if (size1 < 16) {
|
||||
size1 = MIN_BUF_SIZE;
|
||||
if (size < 16) {
|
||||
size = MIN_BUF_SIZE;
|
||||
}
|
||||
this._reset(new Uint8Array(size1), rd1);
|
||||
this._reset(new Uint8Array(size), rd);
|
||||
}
|
||||
size() {
|
||||
return this.buf.byteLength;
|
||||
@ -1292,10 +1292,10 @@ class BufReader {
|
||||
if (p.byteLength === 0) return rr;
|
||||
if (this.r === this.w) {
|
||||
if (p.byteLength >= this.buf.byteLength) {
|
||||
const rr1 = await this.rd.read(p);
|
||||
const nread = rr1 ?? 0;
|
||||
const rr = await this.rd.read(p);
|
||||
const nread = rr ?? 0;
|
||||
assert(nread >= 0, "negative read");
|
||||
return rr1;
|
||||
return rr;
|
||||
}
|
||||
this.r = 0;
|
||||
this.w = 0;
|
||||
@ -1350,18 +1350,18 @@ class BufReader {
|
||||
try {
|
||||
line = await this.readSlice(LF);
|
||||
} catch (err) {
|
||||
let { partial: partial1 } = err;
|
||||
assert(partial1 instanceof Uint8Array, "bufio: caught error from `readSlice()` without `partial` property");
|
||||
let { partial } = err;
|
||||
assert(partial instanceof Uint8Array, "bufio: caught error from `readSlice()` without `partial` property");
|
||||
if (!(err instanceof BufferFullError)) {
|
||||
throw err;
|
||||
}
|
||||
if (!this.eof && partial1.byteLength > 0 && partial1[partial1.byteLength - 1] === CR) {
|
||||
if (!this.eof && partial.byteLength > 0 && partial[partial.byteLength - 1] === CR) {
|
||||
assert(this.r > 0, "bufio: tried to rewind past start of buffer");
|
||||
this.r--;
|
||||
partial1 = partial1.subarray(0, partial1.byteLength - 1);
|
||||
partial = partial.subarray(0, partial.byteLength - 1);
|
||||
}
|
||||
return {
|
||||
line: partial1,
|
||||
line: partial,
|
||||
more: !this.eof
|
||||
};
|
||||
}
|
||||
@ -1387,12 +1387,12 @@ class BufReader {
|
||||
};
|
||||
}
|
||||
async readSlice(delim) {
|
||||
let s1 = 0;
|
||||
let s = 0;
|
||||
let slice;
|
||||
while(true){
|
||||
let i = this.buf.subarray(this.r + s1, this.w).indexOf(delim);
|
||||
let i = this.buf.subarray(this.r + s, this.w).indexOf(delim);
|
||||
if (i >= 0) {
|
||||
i += s1;
|
||||
i += s;
|
||||
slice = this.buf.subarray(this.r, this.r + i + 1);
|
||||
this.r += i + 1;
|
||||
break;
|
||||
@ -1412,7 +1412,7 @@ class BufReader {
|
||||
this.buf = newbuf;
|
||||
throw new BufferFullError(oldbuf);
|
||||
}
|
||||
s1 = this.w - this.r;
|
||||
s = this.w - this.r;
|
||||
try {
|
||||
await this._fill();
|
||||
} catch (err) {
|
||||
@ -1465,13 +1465,13 @@ class BufWriter extends AbstractBufBase {
|
||||
static create(writer, size = 4096) {
|
||||
return writer instanceof BufWriter ? writer : new BufWriter(writer, size);
|
||||
}
|
||||
constructor(writer1, size2 = 4096){
|
||||
constructor(writer, size1 = 4096){
|
||||
super();
|
||||
this.writer = writer1;
|
||||
if (size2 <= 0) {
|
||||
size2 = DEFAULT_BUF_SIZE;
|
||||
this.writer = writer;
|
||||
if (size1 <= 0) {
|
||||
size1 = DEFAULT_BUF_SIZE;
|
||||
}
|
||||
this.buf = new Uint8Array(size2);
|
||||
this.buf = new Uint8Array(size1);
|
||||
}
|
||||
reset(w) {
|
||||
this.err = null;
|
||||
@ -1521,13 +1521,13 @@ class BufWriterSync extends AbstractBufBase {
|
||||
static create(writer, size = 4096) {
|
||||
return writer instanceof BufWriterSync ? writer : new BufWriterSync(writer, size);
|
||||
}
|
||||
constructor(writer2, size3 = 4096){
|
||||
constructor(writer1, size2 = 4096){
|
||||
super();
|
||||
this.writer = writer2;
|
||||
if (size3 <= 0) {
|
||||
size3 = DEFAULT_BUF_SIZE;
|
||||
this.writer = writer1;
|
||||
if (size2 <= 0) {
|
||||
size2 = DEFAULT_BUF_SIZE;
|
||||
}
|
||||
this.buf = new Uint8Array(size3);
|
||||
this.buf = new Uint8Array(size2);
|
||||
}
|
||||
reset(w) {
|
||||
this.err = null;
|
||||
@ -1581,17 +1581,17 @@ function str(buf) {
|
||||
return new TextDecoder().decode(buf);
|
||||
}
|
||||
}
|
||||
function charCode(s1) {
|
||||
return s1.charCodeAt(0);
|
||||
function charCode(s) {
|
||||
return s.charCodeAt(0);
|
||||
}
|
||||
class TextProtoReader {
|
||||
constructor(r){
|
||||
this.r = r;
|
||||
}
|
||||
async readLine() {
|
||||
const s1 = await this.readLineSlice();
|
||||
if (s1 === null) return null;
|
||||
return str(s1);
|
||||
const s = await this.readLineSlice();
|
||||
if (s === null) return null;
|
||||
return str(s);
|
||||
}
|
||||
async readMIMEHeader() {
|
||||
const m = new Headers();
|
||||
@ -1634,9 +1634,9 @@ class TextProtoReader {
|
||||
async readLineSlice() {
|
||||
let line;
|
||||
while(true){
|
||||
const r1 = await this.r.readLine();
|
||||
if (r1 === null) return null;
|
||||
const { line: l , more } = r1;
|
||||
const r = await this.r.readLine();
|
||||
if (r === null) return null;
|
||||
const { line: l , more } = r;
|
||||
if (!line && !more) {
|
||||
if (this.skipSpace(l) === 0) {
|
||||
return new Uint8Array(0);
|
||||
@ -1716,9 +1716,9 @@ function scanUntilBoundary(buf, dashBoundary, newLineDashBoundary, total, eof) {
|
||||
return buf.length;
|
||||
}
|
||||
class PartReader {
|
||||
constructor(mr, headers2){
|
||||
constructor(mr, headers){
|
||||
this.mr = mr;
|
||||
this.headers = headers2;
|
||||
this.headers = headers;
|
||||
this.n = 0;
|
||||
this.total = 0;
|
||||
}
|
||||
@ -1743,8 +1743,8 @@ class PartReader {
|
||||
}
|
||||
const nread = Math.min(p.length, this.n);
|
||||
const buf = p.subarray(0, nread);
|
||||
const r1 = await br.readFull(buf);
|
||||
assert(r1 === buf);
|
||||
const r = await br.readFull(buf);
|
||||
assert(r === buf);
|
||||
this.n -= nread;
|
||||
this.total += nread;
|
||||
return nread;
|
||||
@ -1763,9 +1763,9 @@ class PartReader {
|
||||
).map((kv)=>{
|
||||
const [k, v] = kv.split("=");
|
||||
if (v) {
|
||||
const s1 = v.charAt(0);
|
||||
const s = v.charAt(0);
|
||||
const e = v.charAt(v.length - 1);
|
||||
if (s1 === e && s1 === '"' || s1 === "'") {
|
||||
if (s === e && s === '"' || s === "'") {
|
||||
params[k] = v.substr(1, v.length - 2);
|
||||
} else {
|
||||
params[k] = v;
|
||||
@ -1845,13 +1845,13 @@ class MultipartReader {
|
||||
write: true
|
||||
});
|
||||
try {
|
||||
const size4 = await Deno.copy(new MultiReader(buf, p), file);
|
||||
const size = await Deno.copy(new MultiReader(buf, p), file);
|
||||
file.close();
|
||||
formFile = {
|
||||
filename: p.fileName,
|
||||
type: contentType,
|
||||
tempfile: filepath,
|
||||
size: size4
|
||||
size
|
||||
};
|
||||
} catch (e) {
|
||||
await Deno.remove(filepath);
|
||||
@ -1900,12 +1900,12 @@ class MultipartReader {
|
||||
}
|
||||
if (this.isBoundaryDelimiterLine(line)) {
|
||||
this.partsRead++;
|
||||
const r1 = new TextProtoReader(this.bufReader);
|
||||
const headers1 = await r1.readMIMEHeader();
|
||||
if (headers1 === null) {
|
||||
const r = new TextProtoReader(this.bufReader);
|
||||
const headers = await r.readMIMEHeader();
|
||||
if (headers === null) {
|
||||
throw new Deno.errors.UnexpectedEof();
|
||||
}
|
||||
const np = new PartReader(this, headers1);
|
||||
const np = new PartReader(this, headers);
|
||||
this.currentPart = np;
|
||||
return np;
|
||||
}
|
||||
@ -1977,8 +1977,8 @@ function multipartFormData(fileMap, valueMap) {
|
||||
};
|
||||
}
|
||||
class PartWriter {
|
||||
constructor(writer3, boundary1, headers1, isFirstBoundary){
|
||||
this.writer = writer3;
|
||||
constructor(writer2, boundary1, headers1, isFirstBoundary){
|
||||
this.writer = writer2;
|
||||
this.boundary = boundary1;
|
||||
this.headers = headers1;
|
||||
this.closed = false;
|
||||
@ -1989,8 +1989,8 @@ class PartWriter {
|
||||
} else {
|
||||
buf += `\r\n--${boundary1}\r\n`;
|
||||
}
|
||||
for (const [key, value1] of headers1.entries()){
|
||||
buf += `${key}: ${value1}\r\n`;
|
||||
for (const [key, value] of headers1.entries()){
|
||||
buf += `${key}: ${value}\r\n`;
|
||||
}
|
||||
buf += `\r\n`;
|
||||
this.partHeader = buf;
|
||||
@ -2026,15 +2026,15 @@ class MultipartWriter {
|
||||
get boundary() {
|
||||
return this._boundary;
|
||||
}
|
||||
constructor(writer4, boundary2){
|
||||
this.writer = writer4;
|
||||
constructor(writer3, boundary2){
|
||||
this.writer = writer3;
|
||||
this.isClosed = false;
|
||||
if (boundary2 !== void 0) {
|
||||
this._boundary = checkBoundary(boundary2);
|
||||
} else {
|
||||
this._boundary = randomBoundary();
|
||||
}
|
||||
this.bufWriter = new BufWriter(writer4);
|
||||
this.bufWriter = new BufWriter(writer3);
|
||||
}
|
||||
formDataContentType() {
|
||||
return `multipart/form-data; boundary=${this.boundary}`;
|
||||
|
@ -195,7 +195,7 @@ function isPathSeparator(code) {
|
||||
function isWindowsDeviceRoot(code) {
|
||||
return code >= CHAR_LOWERCASE_A && code <= CHAR_LOWERCASE_Z || code >= CHAR_UPPERCASE_A && code <= CHAR_UPPERCASE_Z;
|
||||
}
|
||||
function normalizeString(path, allowAboveRoot, separator, isPathSeparator1) {
|
||||
function normalizeString(path, allowAboveRoot, separator, isPathSeparator) {
|
||||
let res = "";
|
||||
let lastSegmentLength = 0;
|
||||
let lastSlash = -1;
|
||||
@ -203,9 +203,9 @@ function normalizeString(path, allowAboveRoot, separator, isPathSeparator1) {
|
||||
let code;
|
||||
for(let i = 0, len = path.length; i <= len; ++i){
|
||||
if (i < len) code = path.charCodeAt(i);
|
||||
else if (isPathSeparator1(code)) break;
|
||||
else if (isPathSeparator(code)) break;
|
||||
else code = CHAR_FORWARD_SLASH;
|
||||
if (isPathSeparator1(code)) {
|
||||
if (isPathSeparator(code)) {
|
||||
if (lastSlash === i - 1 || dots === 1) {
|
||||
} else if (lastSlash !== i - 1 && dots === 2) {
|
||||
if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== CHAR_DOT || res.charCodeAt(res.length - 2) !== CHAR_DOT) {
|
||||
@ -925,12 +925,12 @@ function resolve1(...pathSegments) {
|
||||
function normalize1(path) {
|
||||
assertPath(path);
|
||||
if (path.length === 0) return ".";
|
||||
const isAbsolute1 = path.charCodeAt(0) === CHAR_FORWARD_SLASH;
|
||||
const isAbsolute = path.charCodeAt(0) === CHAR_FORWARD_SLASH;
|
||||
const trailingSeparator = path.charCodeAt(path.length - 1) === CHAR_FORWARD_SLASH;
|
||||
path = normalizeString(path, !isAbsolute1, "/", isPosixPathSeparator);
|
||||
if (path.length === 0 && !isAbsolute1) path = ".";
|
||||
path = normalizeString(path, !isAbsolute, "/", isPosixPathSeparator);
|
||||
if (path.length === 0 && !isAbsolute) path = ".";
|
||||
if (path.length > 0 && trailingSeparator) path += "/";
|
||||
if (isAbsolute1) return `/${path}`;
|
||||
if (isAbsolute) return `/${path}`;
|
||||
return path;
|
||||
}
|
||||
function isAbsolute1(path) {
|
||||
@ -1136,9 +1136,9 @@ function parse1(path) {
|
||||
name: ""
|
||||
};
|
||||
if (path.length === 0) return ret;
|
||||
const isAbsolute2 = path.charCodeAt(0) === CHAR_FORWARD_SLASH;
|
||||
const isAbsolute = path.charCodeAt(0) === CHAR_FORWARD_SLASH;
|
||||
let start;
|
||||
if (isAbsolute2) {
|
||||
if (isAbsolute) {
|
||||
ret.root = "/";
|
||||
start = 1;
|
||||
} else {
|
||||
@ -1172,14 +1172,14 @@ function parse1(path) {
|
||||
}
|
||||
if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
|
||||
if (end !== -1) {
|
||||
if (startPart === 0 && isAbsolute2) {
|
||||
if (startPart === 0 && isAbsolute) {
|
||||
ret.base = ret.name = path.slice(1, end);
|
||||
} else {
|
||||
ret.base = ret.name = path.slice(startPart, end);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (startPart === 0 && isAbsolute2) {
|
||||
if (startPart === 0 && isAbsolute) {
|
||||
ret.name = path.slice(1, startDot);
|
||||
ret.base = path.slice(1, end);
|
||||
} else {
|
||||
@ -1189,7 +1189,7 @@ function parse1(path) {
|
||||
ret.ext = path.slice(startDot, end);
|
||||
}
|
||||
if (startPart > 0) ret.dir = path.slice(0, startPart - 1);
|
||||
else if (isAbsolute2) ret.dir = "/";
|
||||
else if (isAbsolute) ret.dir = "/";
|
||||
return ret;
|
||||
}
|
||||
function fromFileUrl1(url) {
|
||||
@ -1250,14 +1250,14 @@ class BufReader {
|
||||
static create(r, size = DEFAULT_BUF_SIZE) {
|
||||
return r instanceof BufReader ? r : new BufReader(r, size);
|
||||
}
|
||||
constructor(rd1, size1 = DEFAULT_BUF_SIZE){
|
||||
constructor(rd, size = DEFAULT_BUF_SIZE){
|
||||
this.r = 0;
|
||||
this.w = 0;
|
||||
this.eof = false;
|
||||
if (size1 < MIN_BUF_SIZE) {
|
||||
size1 = MIN_BUF_SIZE;
|
||||
if (size < MIN_BUF_SIZE) {
|
||||
size = MIN_BUF_SIZE;
|
||||
}
|
||||
this._reset(new Uint8Array(size1), rd1);
|
||||
this._reset(new Uint8Array(size), rd);
|
||||
}
|
||||
size() {
|
||||
return this.buf.byteLength;
|
||||
@ -1301,10 +1301,10 @@ class BufReader {
|
||||
if (p.byteLength === 0) return rr;
|
||||
if (this.r === this.w) {
|
||||
if (p.byteLength >= this.buf.byteLength) {
|
||||
const rr1 = await this.rd.read(p);
|
||||
const nread = rr1 ?? 0;
|
||||
const rr = await this.rd.read(p);
|
||||
const nread = rr ?? 0;
|
||||
assert(nread >= 0, "negative read");
|
||||
return rr1;
|
||||
return rr;
|
||||
}
|
||||
this.r = 0;
|
||||
this.w = 0;
|
||||
@ -1359,18 +1359,18 @@ class BufReader {
|
||||
try {
|
||||
line = await this.readSlice(LF);
|
||||
} catch (err) {
|
||||
let { partial: partial1 } = err;
|
||||
assert(partial1 instanceof Uint8Array, "bufio: caught error from `readSlice()` without `partial` property");
|
||||
let { partial } = err;
|
||||
assert(partial instanceof Uint8Array, "bufio: caught error from `readSlice()` without `partial` property");
|
||||
if (!(err instanceof BufferFullError)) {
|
||||
throw err;
|
||||
}
|
||||
if (!this.eof && partial1.byteLength > 0 && partial1[partial1.byteLength - 1] === CR) {
|
||||
if (!this.eof && partial.byteLength > 0 && partial[partial.byteLength - 1] === CR) {
|
||||
assert(this.r > 0, "bufio: tried to rewind past start of buffer");
|
||||
this.r--;
|
||||
partial1 = partial1.subarray(0, partial1.byteLength - 1);
|
||||
partial = partial.subarray(0, partial.byteLength - 1);
|
||||
}
|
||||
return {
|
||||
line: partial1,
|
||||
line: partial,
|
||||
more: !this.eof
|
||||
};
|
||||
}
|
||||
@ -1396,12 +1396,12 @@ class BufReader {
|
||||
};
|
||||
}
|
||||
async readSlice(delim) {
|
||||
let s1 = 0;
|
||||
let s = 0;
|
||||
let slice;
|
||||
while(true){
|
||||
let i = this.buf.subarray(this.r + s1, this.w).indexOf(delim);
|
||||
let i = this.buf.subarray(this.r + s, this.w).indexOf(delim);
|
||||
if (i >= 0) {
|
||||
i += s1;
|
||||
i += s;
|
||||
slice = this.buf.subarray(this.r, this.r + i + 1);
|
||||
this.r += i + 1;
|
||||
break;
|
||||
@ -1421,7 +1421,7 @@ class BufReader {
|
||||
this.buf = newbuf;
|
||||
throw new BufferFullError(oldbuf);
|
||||
}
|
||||
s1 = this.w - this.r;
|
||||
s = this.w - this.r;
|
||||
try {
|
||||
await this._fill();
|
||||
} catch (err) {
|
||||
@ -1474,13 +1474,13 @@ class BufWriter extends AbstractBufBase {
|
||||
static create(writer, size = DEFAULT_BUF_SIZE) {
|
||||
return writer instanceof BufWriter ? writer : new BufWriter(writer, size);
|
||||
}
|
||||
constructor(writer1, size2 = DEFAULT_BUF_SIZE){
|
||||
constructor(writer, size1 = DEFAULT_BUF_SIZE){
|
||||
super();
|
||||
this.writer = writer1;
|
||||
if (size2 <= 0) {
|
||||
size2 = DEFAULT_BUF_SIZE;
|
||||
this.writer = writer;
|
||||
if (size1 <= 0) {
|
||||
size1 = DEFAULT_BUF_SIZE;
|
||||
}
|
||||
this.buf = new Uint8Array(size2);
|
||||
this.buf = new Uint8Array(size1);
|
||||
}
|
||||
reset(w) {
|
||||
this.err = null;
|
||||
@ -1530,13 +1530,13 @@ class BufWriterSync extends AbstractBufBase {
|
||||
static create(writer, size = DEFAULT_BUF_SIZE) {
|
||||
return writer instanceof BufWriterSync ? writer : new BufWriterSync(writer, size);
|
||||
}
|
||||
constructor(writer2, size3 = DEFAULT_BUF_SIZE){
|
||||
constructor(writer1, size2 = DEFAULT_BUF_SIZE){
|
||||
super();
|
||||
this.writer = writer2;
|
||||
if (size3 <= 0) {
|
||||
size3 = DEFAULT_BUF_SIZE;
|
||||
this.writer = writer1;
|
||||
if (size2 <= 0) {
|
||||
size2 = DEFAULT_BUF_SIZE;
|
||||
}
|
||||
this.buf = new Uint8Array(size3);
|
||||
this.buf = new Uint8Array(size2);
|
||||
}
|
||||
reset(w) {
|
||||
this.err = null;
|
||||
@ -1590,17 +1590,17 @@ function str(buf) {
|
||||
return new TextDecoder().decode(buf);
|
||||
}
|
||||
}
|
||||
function charCode(s1) {
|
||||
return s1.charCodeAt(0);
|
||||
function charCode(s) {
|
||||
return s.charCodeAt(0);
|
||||
}
|
||||
class TextProtoReader {
|
||||
constructor(r){
|
||||
this.r = r;
|
||||
}
|
||||
async readLine() {
|
||||
const s1 = await this.readLineSlice();
|
||||
if (s1 === null) return null;
|
||||
return str(s1);
|
||||
const s = await this.readLineSlice();
|
||||
if (s === null) return null;
|
||||
return str(s);
|
||||
}
|
||||
async readMIMEHeader() {
|
||||
const m = new Headers();
|
||||
@ -1643,9 +1643,9 @@ class TextProtoReader {
|
||||
async readLineSlice() {
|
||||
let line;
|
||||
while(true){
|
||||
const r1 = await this.r.readLine();
|
||||
if (r1 === null) return null;
|
||||
const { line: l , more } = r1;
|
||||
const r = await this.r.readLine();
|
||||
if (r === null) return null;
|
||||
const { line: l , more } = r;
|
||||
if (!line && !more) {
|
||||
if (this.skipSpace(l) === 0) {
|
||||
return new Uint8Array(0);
|
||||
@ -1725,9 +1725,9 @@ function scanUntilBoundary(buf, dashBoundary, newLineDashBoundary, total, eof) {
|
||||
return buf.length;
|
||||
}
|
||||
class PartReader {
|
||||
constructor(mr, headers2){
|
||||
constructor(mr, headers){
|
||||
this.mr = mr;
|
||||
this.headers = headers2;
|
||||
this.headers = headers;
|
||||
this.n = 0;
|
||||
this.total = 0;
|
||||
}
|
||||
@ -1752,8 +1752,8 @@ class PartReader {
|
||||
}
|
||||
const nread = Math.min(p.length, this.n);
|
||||
const buf = p.subarray(0, nread);
|
||||
const r1 = await br.readFull(buf);
|
||||
assert(r1 === buf);
|
||||
const r = await br.readFull(buf);
|
||||
assert(r === buf);
|
||||
this.n -= nread;
|
||||
this.total += nread;
|
||||
return nread;
|
||||
@ -1772,9 +1772,9 @@ class PartReader {
|
||||
).map((kv)=>{
|
||||
const [k, v] = kv.split("=");
|
||||
if (v) {
|
||||
const s1 = v.charAt(0);
|
||||
const s = v.charAt(0);
|
||||
const e = v.charAt(v.length - 1);
|
||||
if (s1 === e && s1 === '"' || s1 === "'") {
|
||||
if (s === e && s === '"' || s === "'") {
|
||||
params[k] = v.substr(1, v.length - 2);
|
||||
} else {
|
||||
params[k] = v;
|
||||
@ -1854,13 +1854,13 @@ class MultipartReader {
|
||||
write: true
|
||||
});
|
||||
try {
|
||||
const size4 = await Deno.copy(new MultiReader(buf, p), file);
|
||||
const size = await Deno.copy(new MultiReader(buf, p), file);
|
||||
file.close();
|
||||
formFile = {
|
||||
filename: p.fileName,
|
||||
type: contentType,
|
||||
tempfile: filepath,
|
||||
size: size4
|
||||
size
|
||||
};
|
||||
} catch (e) {
|
||||
await Deno.remove(filepath);
|
||||
@ -1909,12 +1909,12 @@ class MultipartReader {
|
||||
}
|
||||
if (this.isBoundaryDelimiterLine(line)) {
|
||||
this.partsRead++;
|
||||
const r1 = new TextProtoReader(this.bufReader);
|
||||
const headers1 = await r1.readMIMEHeader();
|
||||
if (headers1 === null) {
|
||||
const r = new TextProtoReader(this.bufReader);
|
||||
const headers = await r.readMIMEHeader();
|
||||
if (headers === null) {
|
||||
throw new Deno.errors.UnexpectedEof();
|
||||
}
|
||||
const np = new PartReader(this, headers1);
|
||||
const np = new PartReader(this, headers);
|
||||
this.currentPart = np;
|
||||
return np;
|
||||
}
|
||||
@ -1986,8 +1986,8 @@ function multipartFormData(fileMap, valueMap) {
|
||||
};
|
||||
}
|
||||
class PartWriter {
|
||||
constructor(writer3, boundary1, headers1, isFirstBoundary){
|
||||
this.writer = writer3;
|
||||
constructor(writer2, boundary1, headers1, isFirstBoundary){
|
||||
this.writer = writer2;
|
||||
this.boundary = boundary1;
|
||||
this.headers = headers1;
|
||||
this.closed = false;
|
||||
@ -1998,8 +1998,8 @@ class PartWriter {
|
||||
} else {
|
||||
buf += `\r\n--${boundary1}\r\n`;
|
||||
}
|
||||
for (const [key, value1] of headers1.entries()){
|
||||
buf += `${key}: ${value1}\r\n`;
|
||||
for (const [key, value] of headers1.entries()){
|
||||
buf += `${key}: ${value}\r\n`;
|
||||
}
|
||||
buf += `\r\n`;
|
||||
this.partHeader = buf;
|
||||
@ -2035,15 +2035,15 @@ class MultipartWriter {
|
||||
get boundary() {
|
||||
return this._boundary;
|
||||
}
|
||||
constructor(writer4, boundary2){
|
||||
this.writer = writer4;
|
||||
constructor(writer3, boundary2){
|
||||
this.writer = writer3;
|
||||
this.isClosed = false;
|
||||
if (boundary2 !== void 0) {
|
||||
this._boundary = checkBoundary(boundary2);
|
||||
} else {
|
||||
this._boundary = randomBoundary();
|
||||
}
|
||||
this.bufWriter = new BufWriter(writer4);
|
||||
this.bufWriter = new BufWriter(writer3);
|
||||
}
|
||||
formDataContentType() {
|
||||
return `multipart/form-data; boundary=${this.boundary}`;
|
||||
|
@ -2,10 +2,10 @@ function a() {
|
||||
console.log("a");
|
||||
}
|
||||
var O1;
|
||||
(function(O1) {
|
||||
O1[O1["A"] = 0] = "A";
|
||||
O1[O1["B"] = 1] = "B";
|
||||
O1[O1["C"] = 2] = "C";
|
||||
(function(O) {
|
||||
O[O["A"] = 0] = "A";
|
||||
O[O["B"] = 1] = "B";
|
||||
O[O["C"] = 2] = "C";
|
||||
})(O1 || (O1 = {
|
||||
}));
|
||||
export { O1 as O };
|
||||
|
@ -2,10 +2,10 @@ function a() {
|
||||
console.log("a");
|
||||
}
|
||||
var O1;
|
||||
(function(O1) {
|
||||
O1[O1["A"] = 0] = "A";
|
||||
O1[O1["B"] = 1] = "B";
|
||||
O1[O1["C"] = 2] = "C";
|
||||
(function(O) {
|
||||
O[O["A"] = 0] = "A";
|
||||
O[O["B"] = 1] = "B";
|
||||
O[O["C"] = 2] = "C";
|
||||
})(O1 || (O1 = {
|
||||
}));
|
||||
export { O1 as O };
|
||||
|
@ -2,10 +2,10 @@ function a() {
|
||||
console.log("a");
|
||||
}
|
||||
var O1;
|
||||
(function(O1) {
|
||||
O1[O1["A"] = 0] = "A";
|
||||
O1[O1["B"] = 1] = "B";
|
||||
O1[O1["C"] = 2] = "C";
|
||||
(function(O) {
|
||||
O[O["A"] = 0] = "A";
|
||||
O[O["B"] = 1] = "B";
|
||||
O[O["C"] = 2] = "C";
|
||||
})(O1 || (O1 = {
|
||||
}));
|
||||
export { O1 as O };
|
||||
|
@ -2,10 +2,10 @@ function a() {
|
||||
console.log("a");
|
||||
}
|
||||
var O1;
|
||||
(function(O1) {
|
||||
O1[O1["A"] = 0] = "A";
|
||||
O1[O1["B"] = 1] = "B";
|
||||
O1[O1["C"] = 2] = "C";
|
||||
(function(O) {
|
||||
O[O["A"] = 0] = "A";
|
||||
O[O["B"] = 1] = "B";
|
||||
O[O["C"] = 2] = "C";
|
||||
})(O1 || (O1 = {
|
||||
}));
|
||||
export { O1 as O };
|
||||
|
@ -1,7 +1,7 @@
|
||||
var A;
|
||||
(function(A1) {
|
||||
A1[A1["b"] = 5] = "b";
|
||||
A1[A1["c"] = 28] = "c";
|
||||
(function(A) {
|
||||
A[A["b"] = 5] = "b";
|
||||
A[A["c"] = 28] = "c";
|
||||
})(A || (A = {
|
||||
}));
|
||||
function foo() {
|
||||
|
@ -1,7 +1,7 @@
|
||||
var A;
|
||||
(function(A1) {
|
||||
A1[A1["b"] = 5] = "b";
|
||||
A1[A1["c"] = 28] = "c";
|
||||
(function(A) {
|
||||
A[A["b"] = 5] = "b";
|
||||
A[A["c"] = 28] = "c";
|
||||
})(A || (A = {
|
||||
}));
|
||||
function foo() {
|
||||
|
@ -1,6 +1,6 @@
|
||||
var Status1;
|
||||
(function(Status1) {
|
||||
Status1[Status1["Continue"] = 100] = "Continue";
|
||||
(function(Status) {
|
||||
Status[Status["Continue"] = 100] = "Continue";
|
||||
})(Status1 || (Status1 = {
|
||||
}));
|
||||
export { Status1 as Status };
|
||||
|
@ -1,6 +1,6 @@
|
||||
var Status1;
|
||||
(function(Status1) {
|
||||
Status1[Status1["Continue"] = 100] = "Continue";
|
||||
(function(Status) {
|
||||
Status[Status["Continue"] = 100] = "Continue";
|
||||
})(Status1 || (Status1 = {
|
||||
}));
|
||||
export { Status1 as Status };
|
||||
|
@ -6,7 +6,7 @@ edition = "2018"
|
||||
license = "Apache-2.0/MIT"
|
||||
name = "swc_ecmascript"
|
||||
repository = "https://github.com/swc-project/swc.git"
|
||||
version = "0.60.0"
|
||||
version = "0.61.0"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
@ -35,7 +35,7 @@ typescript = ["typescript-parser", "swc_ecma_transforms/typescript"]
|
||||
swc_ecma_ast = {version = "0.51.1", path = "./ast"}
|
||||
swc_ecma_codegen = {version = "0.69.1", path = "./codegen", optional = true}
|
||||
swc_ecma_dep_graph = {version = "0.38.1", path = "./dep-graph", optional = true}
|
||||
swc_ecma_minifier = {version = "0.24.0", path = "./minifier", optional = true}
|
||||
swc_ecma_minifier = {version = "0.25.0", path = "./minifier", optional = true}
|
||||
swc_ecma_parser = {version = "0.69.1", path = "./parser", optional = true, default-features = false}
|
||||
swc_ecma_preset_env = {version = "0.40.0", path = "./preset-env", optional = true}
|
||||
swc_ecma_transforms = {version = "0.69.0", path = "./transforms", optional = true}
|
||||
|
@ -7,7 +7,7 @@ include = ["Cargo.toml", "src/**/*.rs", "src/lists/*.json"]
|
||||
license = "Apache-2.0/MIT"
|
||||
name = "swc_ecma_minifier"
|
||||
repository = "https://github.com/swc-project/swc.git"
|
||||
version = "0.24.0"
|
||||
version = "0.25.0"
|
||||
|
||||
[features]
|
||||
debug = []
|
||||
|
@ -12,10 +12,7 @@
|
||||
//! them something other. Don't call methods like `visit_mut_script` nor
|
||||
//! `visit_mut_module_items`.
|
||||
|
||||
pub use crate::pass::{
|
||||
hygiene::{hygiene_optimizer, optimize_hygiene},
|
||||
unique_scope::unique_scope,
|
||||
};
|
||||
pub use crate::pass::unique_scope::unique_scope;
|
||||
use crate::{
|
||||
compress::compressor,
|
||||
marks::Marks,
|
||||
@ -159,11 +156,6 @@ pub fn optimize(
|
||||
t.section("hygiene");
|
||||
}
|
||||
|
||||
{
|
||||
m.visit_mut_with(&mut unique_scope());
|
||||
m.visit_mut_with(&mut hygiene_optimizer(extra.top_level_mark));
|
||||
}
|
||||
|
||||
if let Some(ref mut t) = timings {
|
||||
t.end_section();
|
||||
}
|
||||
|
@ -1,148 +0,0 @@
|
||||
use crate::analyzer::{ProgramData, ScopeData};
|
||||
use fxhash::FxHashSet;
|
||||
use swc_common::{Mark, SyntaxContext};
|
||||
use swc_ecma_ast::*;
|
||||
use swc_ecma_utils::{ident::IdentLike, Id};
|
||||
use swc_ecma_visit::{noop_visit_type, Node, Visit, VisitWith};
|
||||
|
||||
pub(super) struct HygieneAnalyzer<'a> {
|
||||
pub data: &'a ProgramData,
|
||||
pub hygiene: HygieneData,
|
||||
pub top_level_mark: Mark,
|
||||
pub cur_scope: Option<SyntaxContext>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub(super) struct HygieneData {
|
||||
/// Has higher precedence over `modified`.
|
||||
pub preserved: FxHashSet<Id>,
|
||||
|
||||
pub modified: FxHashSet<Id>,
|
||||
}
|
||||
|
||||
impl HygieneAnalyzer<'_> {
|
||||
fn scope(&self) -> &ScopeData {
|
||||
match self.cur_scope {
|
||||
Some(v) => self.data.scopes.get(&v).expect("failed to get scope"),
|
||||
None => &self.data.top,
|
||||
}
|
||||
}
|
||||
|
||||
fn with_scope<F, Ret>(&mut self, scope_ctxt: SyntaxContext, op: F) -> Ret
|
||||
where
|
||||
F: FnOnce(&mut HygieneAnalyzer) -> Ret,
|
||||
{
|
||||
let old = self.cur_scope;
|
||||
self.cur_scope = Some(scope_ctxt);
|
||||
|
||||
let ret = op(self);
|
||||
|
||||
let mut ids = vec![];
|
||||
{
|
||||
let scope = self.scope();
|
||||
for (sym, ctxts) in &scope.declared_symbols {
|
||||
if ctxts.len() == 1 {
|
||||
let id = (sym.clone(), *ctxts.iter().next().unwrap());
|
||||
ids.push(id)
|
||||
}
|
||||
}
|
||||
}
|
||||
for id in ids {
|
||||
self.hygiene.preserved.remove(&id);
|
||||
self.hygiene.modified.insert(id);
|
||||
}
|
||||
|
||||
self.cur_scope = old;
|
||||
|
||||
ret
|
||||
}
|
||||
}
|
||||
|
||||
impl Visit for HygieneAnalyzer<'_> {
|
||||
noop_visit_type!();
|
||||
|
||||
fn visit_function(&mut self, n: &Function, _: &dyn Node) {
|
||||
self.with_scope(n.span.ctxt, |v| {
|
||||
n.visit_children_with(v);
|
||||
});
|
||||
}
|
||||
|
||||
fn visit_ident(&mut self, i: &Ident, _: &dyn Node) {
|
||||
if cfg!(feature = "debug") {
|
||||
log::trace!("hygiene: Handling ({})", i);
|
||||
}
|
||||
|
||||
if i.span.ctxt == SyntaxContext::empty() {
|
||||
return;
|
||||
}
|
||||
|
||||
if i.span.has_mark(self.top_level_mark) {
|
||||
return;
|
||||
}
|
||||
|
||||
let info = self.data.vars.get(&i.to_id());
|
||||
// Ignore labels.
|
||||
let info = match info {
|
||||
Some(v) => v,
|
||||
None => {
|
||||
if cfg!(feature = "debug") {
|
||||
log::trace!("hygiene: No such var: {}{:?}", i.sym, i.span.ctxt);
|
||||
}
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
// If multiple variables with same name is declared, skip it.
|
||||
if let Some(decls) = self.scope().declared_symbols.get(&i.sym) {
|
||||
if decls.len() >= 2 {
|
||||
self.hygiene.preserved.insert(i.to_id());
|
||||
if cfg!(feature = "debug") {
|
||||
log::trace!(
|
||||
"hygiene: Preserving hygiene of {}{:?} because it's declared multiple \
|
||||
times",
|
||||
i.sym,
|
||||
i.span.ctxt
|
||||
);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if info.is_fn_local || info.declared_as_fn_expr {
|
||||
if cfg!(feature = "debug") {
|
||||
log::trace!(
|
||||
"hygiene: Optimization candidate: {}{:?}",
|
||||
i.sym,
|
||||
i.span.ctxt
|
||||
);
|
||||
}
|
||||
self.hygiene.modified.insert(i.to_id());
|
||||
} else {
|
||||
if cfg!(feature = "debug") {
|
||||
log::trace!(
|
||||
"hygiene: Preserving {}{:?} as it is not fn-local",
|
||||
i.sym,
|
||||
i.span.ctxt
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_member_expr(&mut self, n: &MemberExpr, _: &dyn Node) {
|
||||
n.obj.visit_with(n, self);
|
||||
|
||||
if n.computed {
|
||||
n.prop.visit_with(n, self);
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_prop_name(&mut self, n: &PropName, _: &dyn Node) {
|
||||
match n {
|
||||
PropName::Computed(..) => {
|
||||
n.visit_children_with(self);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,129 +0,0 @@
|
||||
use crate::{
|
||||
analyzer::{analyze, ProgramData},
|
||||
pass::hygiene::analyzer::{HygieneAnalyzer, HygieneData},
|
||||
util::now,
|
||||
};
|
||||
use std::time::Instant;
|
||||
use swc_common::{Mark, SyntaxContext, DUMMY_SP};
|
||||
use swc_ecma_ast::*;
|
||||
use swc_ecma_utils::ident::IdentLike;
|
||||
use swc_ecma_visit::{as_folder, noop_visit_mut_type, Fold, VisitMut, VisitMutWith, VisitWith};
|
||||
|
||||
mod analyzer;
|
||||
|
||||
/// Optimize hygiene info to get minified output.
|
||||
///
|
||||
/// Requires [swc_common::GLOBALS].
|
||||
pub fn optimize_hygiene(m: &mut Module, top_level_mark: Mark) {
|
||||
m.visit_mut_with(&mut hygiene_optimizer(top_level_mark))
|
||||
}
|
||||
|
||||
/// Create a hygiene optimizer.
|
||||
///
|
||||
/// Hygiene optimizer removes span hygiene without renaming if it's ok to do so.
|
||||
///
|
||||
/// # Usage
|
||||
///
|
||||
/// You have to apply [crate::unique_scope] before this. Otherwise, this will
|
||||
/// break code.
|
||||
pub fn hygiene_optimizer(top_level_mark: Mark) -> impl 'static + VisitMut + Fold {
|
||||
as_folder(Optimizer {
|
||||
data: Default::default(),
|
||||
hygiene: Default::default(),
|
||||
top_level_mark,
|
||||
})
|
||||
}
|
||||
|
||||
struct Optimizer {
|
||||
data: ProgramData,
|
||||
hygiene: HygieneData,
|
||||
top_level_mark: Mark,
|
||||
}
|
||||
|
||||
impl Optimizer {}
|
||||
|
||||
impl VisitMut for Optimizer {
|
||||
noop_visit_mut_type!();
|
||||
|
||||
fn visit_mut_ident(&mut self, i: &mut Ident) {
|
||||
if i.span.ctxt == SyntaxContext::empty() {
|
||||
return;
|
||||
}
|
||||
|
||||
if self.hygiene.preserved.contains(&i.to_id())
|
||||
|| !self.hygiene.modified.contains(&i.to_id())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
i.span.ctxt = SyntaxContext::empty().apply_mark(self.top_level_mark);
|
||||
}
|
||||
|
||||
fn visit_mut_member_expr(&mut self, n: &mut MemberExpr) {
|
||||
n.obj.visit_mut_with(self);
|
||||
|
||||
if n.computed {
|
||||
n.prop.visit_mut_with(self);
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_mut_module(&mut self, n: &mut Module) {
|
||||
log::info!("hygiene: Analyzing span hygiene");
|
||||
let start = now();
|
||||
|
||||
self.data = analyze(&*n, None);
|
||||
|
||||
let mut analyzer = HygieneAnalyzer {
|
||||
data: &self.data,
|
||||
hygiene: Default::default(),
|
||||
top_level_mark: self.top_level_mark,
|
||||
cur_scope: None,
|
||||
};
|
||||
n.visit_with(&Invalid { span: DUMMY_SP }, &mut analyzer);
|
||||
self.hygiene = analyzer.hygiene;
|
||||
|
||||
if let Some(start) = start {
|
||||
let end = Instant::now();
|
||||
log::info!("hygiene: Span hygiene analysis took {:?}", end - start);
|
||||
}
|
||||
let start = now();
|
||||
|
||||
log::info!("hygiene: Optimizing span hygiene");
|
||||
n.visit_mut_children_with(self);
|
||||
|
||||
if let Some(start) = start {
|
||||
let end = Instant::now();
|
||||
log::info!("hygiene: Span hygiene optimiation took {:?}", end - start);
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_mut_script(&mut self, n: &mut Script) {
|
||||
log::info!("hygiene: Analyzing span hygiene");
|
||||
let start = now();
|
||||
|
||||
self.data = analyze(&*n, None);
|
||||
|
||||
let mut analyzer = HygieneAnalyzer {
|
||||
data: &self.data,
|
||||
hygiene: Default::default(),
|
||||
top_level_mark: self.top_level_mark,
|
||||
cur_scope: None,
|
||||
};
|
||||
n.visit_with(&Invalid { span: DUMMY_SP }, &mut analyzer);
|
||||
self.hygiene = analyzer.hygiene;
|
||||
|
||||
if let Some(start) = start {
|
||||
let end = Instant::now();
|
||||
log::info!("hygiene: Span hygiene analysis took {:?}", end - start);
|
||||
}
|
||||
let start = now();
|
||||
|
||||
log::info!("hygiene: Optimizing span hygiene");
|
||||
n.visit_mut_children_with(self);
|
||||
|
||||
if let Some(start) = start {
|
||||
let end = Instant::now();
|
||||
log::info!("hygiene: Span hygiene optimiation took {:?}", end - start);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
pub mod compute_char_freq;
|
||||
pub mod expand_names;
|
||||
pub mod global_defs;
|
||||
pub mod hygiene;
|
||||
pub mod mangle_names;
|
||||
pub mod mangle_props;
|
||||
pub mod postcompress;
|
||||
|
@ -1,68 +0,0 @@
|
||||
use std::path::PathBuf;
|
||||
use swc_common::{input::SourceFileInput, sync::Lrc, Mark, SourceMap};
|
||||
use swc_ecma_codegen::{text_writer::JsWriter, Emitter};
|
||||
use swc_ecma_minifier::optimize_hygiene;
|
||||
use swc_ecma_parser::{lexer::Lexer, Parser};
|
||||
use swc_ecma_transforms::{fixer, hygiene, resolver_with_mark};
|
||||
use swc_ecma_utils::drop_span;
|
||||
use swc_ecma_visit::FoldWith;
|
||||
use testing::{assert_eq, run_test2, DebugUsingDisplay};
|
||||
|
||||
#[testing::fixture("tests/hygiene/identical/**/*.js")]
|
||||
fn identical(input: PathBuf) {
|
||||
run_test2(false, |cm, handler| {
|
||||
let fm = cm.load_file(&input).expect("failed to load input.js");
|
||||
|
||||
let top_level_mark = Mark::fresh(Mark::root());
|
||||
|
||||
let lexer = Lexer::new(
|
||||
Default::default(),
|
||||
Default::default(),
|
||||
SourceFileInput::from(&*fm),
|
||||
None,
|
||||
);
|
||||
|
||||
let mut parser = Parser::new_from(lexer);
|
||||
let program = parser.parse_module().map_err(|err| {
|
||||
err.into_diagnostic(&handler).emit();
|
||||
});
|
||||
|
||||
let mut program = program
|
||||
.map(|module| module.fold_with(&mut resolver_with_mark(top_level_mark)))
|
||||
.unwrap();
|
||||
|
||||
let expected = print(cm.clone(), &[drop_span(program.clone())]);
|
||||
|
||||
optimize_hygiene(&mut program, top_level_mark);
|
||||
|
||||
let program = program
|
||||
.fold_with(&mut hygiene())
|
||||
.fold_with(&mut fixer(None));
|
||||
|
||||
let actual = print(cm.clone(), &[program]);
|
||||
|
||||
assert_eq!(DebugUsingDisplay(&*expected), DebugUsingDisplay(&*actual));
|
||||
|
||||
Ok(())
|
||||
})
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
fn print<N: swc_ecma_codegen::Node>(cm: Lrc<SourceMap>, nodes: &[N]) -> String {
|
||||
let mut buf = vec![];
|
||||
|
||||
{
|
||||
let mut emitter = Emitter {
|
||||
cfg: Default::default(),
|
||||
cm: cm.clone(),
|
||||
comments: None,
|
||||
wr: Box::new(JsWriter::new(cm.clone(), "\n", &mut buf, None)),
|
||||
};
|
||||
|
||||
for n in nodes {
|
||||
n.emit_with(&mut emitter).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
String::from_utf8(buf).unwrap()
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
|
||||
|
||||
const foo = 1;
|
||||
|
||||
const bar = (foo) => foo;
|
@ -1,3 +0,0 @@
|
||||
var foo = ([]) => "foo";
|
||||
var bar = ({ }) => "bar";
|
||||
var with_default = (foo = "default") => foo
|
@ -241,7 +241,7 @@
|
||||
return 3 === element[0].nodeType ? lowercase(elemHtml) : elemHtml.match(/^(<[^>]+>)/)[1].replace(/^<([\w\-]+)/, function(match, nodeName) {
|
||||
return "<" + lowercase(nodeName);
|
||||
});
|
||||
} catch (e) {
|
||||
} catch (e1) {
|
||||
return lowercase(elemHtml);
|
||||
}
|
||||
}
|
||||
@ -380,7 +380,7 @@
|
||||
var modules = {
|
||||
};
|
||||
return function(name, requires, configFn) {
|
||||
return (function(name, context) {
|
||||
return (function(name1, context) {
|
||||
if ("hasOwnProperty" === name) throw ngMinErr("badname", "hasOwnProperty is not a valid {0} name", "module");
|
||||
})(name, "module"), requires && modules.hasOwnProperty(name) && (modules[name] = null), ensure(modules, name, function() {
|
||||
if (!requires) throw $injectorMinErr("nomod", "Module '{0}' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.", name);
|
||||
@ -1389,8 +1389,8 @@
|
||||
var scopeToChild = scope;
|
||||
for(newIsolateScopeDirective && (newIsolateScopeDirective.template || null === newIsolateScopeDirective.templateUrl) && (scopeToChild = isolateScope), childLinkFn && childLinkFn(scopeToChild, linkNode.childNodes, undefined, boundTranscludeFn), i = postLinkFns.length - 1; i >= 0; i--)try {
|
||||
(linkFn = postLinkFns[i])(linkFn.isolateScope ? isolateScope : scope, $element, attrs, linkFn.require && getControllers(linkFn.require, $element, elementControllers), transcludeFn);
|
||||
} catch (e) {
|
||||
$exceptionHandler(e, startingTag($element));
|
||||
} catch (e1) {
|
||||
$exceptionHandler(e1, startingTag($element));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2309,9 +2309,9 @@
|
||||
};
|
||||
if (OPERATORS.hasOwnProperty(ident)) token.fn = OPERATORS[ident], token.json = OPERATORS[ident];
|
||||
else {
|
||||
var getter1 = getterFn(ident, this.options, this.text);
|
||||
var getter = getterFn(ident, this.options, this.text);
|
||||
token.fn = extend(function(self, locals) {
|
||||
return getter1(self, locals);
|
||||
return getter(self, locals);
|
||||
}, {
|
||||
assign: function(self, value) {
|
||||
return setter(self, ident, value, parser.text, parser.options);
|
||||
@ -2518,9 +2518,9 @@
|
||||
return this.expect("+") ? this.primary() : (token = this.expect("-")) ? this.binaryFn(Parser.ZERO, token.fn, this.unary()) : (token = this.expect("!")) ? this.unaryFn(token.fn, this.unary()) : this.primary();
|
||||
},
|
||||
fieldAccess: function(object) {
|
||||
var parser = this, field = this.expect().text, getter2 = getterFn(field, this.options, this.text);
|
||||
var parser = this, field = this.expect().text, getter = getterFn(field, this.options, this.text);
|
||||
return extend(function(scope, locals, self) {
|
||||
return getter2(self || object(scope, locals), locals);
|
||||
return getter(self || object(scope, locals), locals);
|
||||
}, {
|
||||
assign: function(scope, value, locals) {
|
||||
return setter(object(scope, locals), field, value, parser.text, parser.options);
|
||||
@ -4264,12 +4264,12 @@
|
||||
requiredValidator(ngModelCtrl1.$viewValue);
|
||||
});
|
||||
}
|
||||
optionsExp ? (function(scope2, selectElement2, ctrl1) {
|
||||
if (!(match = optionsExp.match(NG_OPTIONS_REGEXP))) throw ngOptionsMinErr("iexp", "Expected expression in form of '_select_ (as _label_)? for (_key_,)?_value_ in _collection_' but got '{0}'. Element: {1}", optionsExp, startingTag(selectElement2));
|
||||
optionsExp ? (function(scope, selectElement, ctrl) {
|
||||
if (!(match = optionsExp.match(NG_OPTIONS_REGEXP))) throw ngOptionsMinErr("iexp", "Expected expression in form of '_select_ (as _label_)? for (_key_,)?_value_ in _collection_' but got '{0}'. Element: {1}", optionsExp, startingTag(selectElement));
|
||||
var match, displayFn = $parse(match[2] || match[1]), valueName = match[4] || match[6], keyName = match[5], groupByFn = $parse(match[3] || ""), valueFn = $parse(match[2] ? match[1] : valueName), valuesFn = $parse(match[7]), trackFn = match[8] ? $parse(match[8]) : null, optionGroupsCache = [
|
||||
[
|
||||
{
|
||||
element: selectElement2,
|
||||
element: selectElement,
|
||||
label: ""
|
||||
}
|
||||
]
|
||||
@ -4279,28 +4279,28 @@
|
||||
"": []
|
||||
}, optionGroupNames = [
|
||||
""
|
||||
], modelValue = ctrl1.$modelValue, values = valuesFn(scope2) || [], keys = keyName ? sortedKeys(values) : values, locals = {
|
||||
], modelValue = ctrl.$modelValue, values = valuesFn(scope) || [], keys = keyName ? sortedKeys(values) : values, locals = {
|
||||
}, selectedSet = !1;
|
||||
if (multiple) if (trackFn && isArray(modelValue)) {
|
||||
selectedSet = new HashMap([]);
|
||||
for(var trackIndex = 0; trackIndex < modelValue.length; trackIndex++)locals[valueName] = modelValue[trackIndex], selectedSet.put(trackFn(scope2, locals), modelValue[trackIndex]);
|
||||
for(var trackIndex = 0; trackIndex < modelValue.length; trackIndex++)locals[valueName] = modelValue[trackIndex], selectedSet.put(trackFn(scope, locals), modelValue[trackIndex]);
|
||||
} else selectedSet = new HashMap(modelValue);
|
||||
for(index = 0; index < (length = keys.length); index++){
|
||||
if (key = index, keyName) {
|
||||
if ("$" === (key = keys[index]).charAt(0)) continue;
|
||||
locals[keyName] = key;
|
||||
}
|
||||
if (locals[valueName] = values[key], (optionGroup = optionGroups[optionGroupName = groupByFn(scope2, locals) || ""]) || (optionGroup = optionGroups[optionGroupName] = [], optionGroupNames.push(optionGroupName)), multiple) selected = isDefined(selectedSet.remove(trackFn ? trackFn(scope2, locals) : valueFn(scope2, locals)));
|
||||
if (locals[valueName] = values[key], (optionGroup = optionGroups[optionGroupName = groupByFn(scope, locals) || ""]) || (optionGroup = optionGroups[optionGroupName] = [], optionGroupNames.push(optionGroupName)), multiple) selected = isDefined(selectedSet.remove(trackFn ? trackFn(scope, locals) : valueFn(scope, locals)));
|
||||
else {
|
||||
if (trackFn) {
|
||||
var modelCast = {
|
||||
};
|
||||
modelCast[valueName] = modelValue, selected = trackFn(scope2, modelCast) === trackFn(scope2, locals);
|
||||
} else selected = modelValue === valueFn(scope2, locals);
|
||||
modelCast[valueName] = modelValue, selected = trackFn(scope, modelCast) === trackFn(scope, locals);
|
||||
} else selected = modelValue === valueFn(scope, locals);
|
||||
selectedSet = selectedSet || selected;
|
||||
}
|
||||
label = isDefined(label = displayFn(scope2, locals)) ? label : "", optionGroup.push({
|
||||
id: trackFn ? trackFn(scope2, locals) : keyName ? keys[index] : index,
|
||||
label = isDefined(label = displayFn(scope, locals)) ? label : "", optionGroup.push({
|
||||
id: trackFn ? trackFn(scope, locals) : keyName ? keys[index] : index,
|
||||
label: label,
|
||||
selected: selected
|
||||
});
|
||||
@ -4319,7 +4319,7 @@
|
||||
element: optGroupTemplate.clone().attr("label", optionGroupName),
|
||||
label: optionGroup.label
|
||||
}
|
||||
], optionGroupsCache.push(existingOptions), selectElement2.append(existingParent.element)) : (existingParent = (existingOptions = optionGroupsCache[groupIndex])[0]).label != optionGroupName && existingParent.element.attr("label", existingParent.label = optionGroupName), lastElement = null, index = 0, length = optionGroup.length; index < length; index++)option = optionGroup[index], (existingOption = existingOptions[index + 1]) ? (lastElement = existingOption.element, existingOption.label !== option.label && lastElement.text(existingOption.label = option.label), existingOption.id !== option.id && lastElement.val(existingOption.id = option.id), lastElement[0].selected !== option.selected && lastElement.prop("selected", existingOption.selected = option.selected)) : ("" === option.id && nullOption ? element = nullOption : (element = optionTemplate.clone()).val(option.id).attr("selected", option.selected).text(option.label), existingOptions.push(existingOption = {
|
||||
], optionGroupsCache.push(existingOptions), selectElement.append(existingParent.element)) : (existingParent = (existingOptions = optionGroupsCache[groupIndex])[0]).label != optionGroupName && existingParent.element.attr("label", existingParent.label = optionGroupName), lastElement = null, index = 0, length = optionGroup.length; index < length; index++)option = optionGroup[index], (existingOption = existingOptions[index + 1]) ? (lastElement = existingOption.element, existingOption.label !== option.label && lastElement.text(existingOption.label = option.label), existingOption.id !== option.id && lastElement.val(existingOption.id = option.id), lastElement[0].selected !== option.selected && lastElement.prop("selected", existingOption.selected = option.selected)) : ("" === option.id && nullOption ? element = nullOption : (element = optionTemplate.clone()).val(option.id).attr("selected", option.selected).text(option.label), existingOptions.push(existingOption = {
|
||||
element: element,
|
||||
label: option.label,
|
||||
id: option.id,
|
||||
@ -4329,27 +4329,27 @@
|
||||
}
|
||||
for(; optionGroupsCache.length > groupIndex;)optionGroupsCache.pop()[0].element.remove();
|
||||
}
|
||||
nullOption && ($compile(nullOption)(scope2), nullOption.removeClass("ng-scope"), nullOption.remove()), selectElement2.empty(), selectElement2.on("change", function() {
|
||||
scope2.$apply(function() {
|
||||
var optionGroup, key, value, optionElement, index, groupIndex, length, groupLength, trackIndex, collection = valuesFn(scope2) || [], locals = {
|
||||
nullOption && ($compile(nullOption)(scope), nullOption.removeClass("ng-scope"), nullOption.remove()), selectElement.empty(), selectElement.on("change", function() {
|
||||
scope.$apply(function() {
|
||||
var optionGroup, key, value, optionElement, index, groupIndex, length, groupLength, trackIndex, collection = valuesFn(scope) || [], locals = {
|
||||
};
|
||||
if (multiple) {
|
||||
for(groupIndex = 0, value = [], groupLength = optionGroupsCache.length; groupIndex < groupLength; groupIndex++)for(index = 1, length = (optionGroup = optionGroupsCache[groupIndex]).length; index < length; index++)if ((optionElement = optionGroup[index].element)[0].selected) {
|
||||
if (key = optionElement.val(), keyName && (locals[keyName] = key), trackFn) for(trackIndex = 0; trackIndex < collection.length && (locals[valueName] = collection[trackIndex], trackFn(scope2, locals) != key); trackIndex++);
|
||||
if (key = optionElement.val(), keyName && (locals[keyName] = key), trackFn) for(trackIndex = 0; trackIndex < collection.length && (locals[valueName] = collection[trackIndex], trackFn(scope, locals) != key); trackIndex++);
|
||||
else locals[valueName] = collection[key];
|
||||
value.push(valueFn(scope2, locals));
|
||||
value.push(valueFn(scope, locals));
|
||||
}
|
||||
} else if ("?" == (key = selectElement2.val())) value = undefined;
|
||||
} else if ("?" == (key = selectElement.val())) value = undefined;
|
||||
else if ("" === key) value = null;
|
||||
else if (trackFn) {
|
||||
for(trackIndex = 0; trackIndex < collection.length; trackIndex++)if (locals[valueName] = collection[trackIndex], trackFn(scope2, locals) == key) {
|
||||
value = valueFn(scope2, locals);
|
||||
for(trackIndex = 0; trackIndex < collection.length; trackIndex++)if (locals[valueName] = collection[trackIndex], trackFn(scope, locals) == key) {
|
||||
value = valueFn(scope, locals);
|
||||
break;
|
||||
}
|
||||
} else locals[valueName] = collection[key], keyName && (locals[keyName] = key), value = valueFn(scope2, locals);
|
||||
ctrl1.$setViewValue(value);
|
||||
} else locals[valueName] = collection[key], keyName && (locals[keyName] = key), value = valueFn(scope, locals);
|
||||
ctrl.$setViewValue(value);
|
||||
});
|
||||
}), ctrl1.$render = render, scope2.$watch(render);
|
||||
}), ctrl.$render = render, scope.$watch(render);
|
||||
})(scope, element, ngModelCtrl1) : multiple ? (scope1 = scope, selectElement = element, (ctrl = ngModelCtrl1).$render = function() {
|
||||
var items = new HashMap(ctrl.$viewValue);
|
||||
forEach(selectElement.find("option"), function(option) {
|
||||
@ -4389,12 +4389,12 @@
|
||||
var interpolateFn = $interpolate(element.text(), !0);
|
||||
interpolateFn || attr.$set("value", element.text());
|
||||
}
|
||||
return function(scope5, element, attr) {
|
||||
var parent = element.parent(), selectCtrl1 = parent.data("$selectController") || parent.parent().data("$selectController");
|
||||
selectCtrl1 && selectCtrl1.databound ? element.prop("selected", !1) : selectCtrl1 = nullSelectCtrl, interpolateFn ? scope5.$watch(interpolateFn, function(newVal, oldVal) {
|
||||
attr.$set("value", newVal), newVal !== oldVal && selectCtrl1.removeOption(oldVal), selectCtrl1.addOption(newVal);
|
||||
}) : selectCtrl1.addOption(attr.value), element.on("$destroy", function() {
|
||||
selectCtrl1.removeOption(attr.value);
|
||||
return function(scope, element, attr) {
|
||||
var parent = element.parent(), selectCtrl = parent.data("$selectController") || parent.parent().data("$selectController");
|
||||
selectCtrl && selectCtrl.databound ? element.prop("selected", !1) : selectCtrl = nullSelectCtrl, interpolateFn ? scope.$watch(interpolateFn, function(newVal, oldVal) {
|
||||
attr.$set("value", newVal), newVal !== oldVal && selectCtrl.removeOption(oldVal), selectCtrl.addOption(newVal);
|
||||
}) : selectCtrl.addOption(attr.value), element.on("$destroy", function() {
|
||||
selectCtrl.removeOption(attr.value);
|
||||
});
|
||||
};
|
||||
}
|
||||
@ -4409,7 +4409,7 @@
|
||||
controller: JQLitePrototype.controller,
|
||||
injector: JQLitePrototype.injector,
|
||||
inheritedData: JQLitePrototype.inheritedData
|
||||
}), jqLitePatchJQueryRemove("remove", !0, !0, !1), jqLitePatchJQueryRemove("empty", !1, !1, !1), jqLitePatchJQueryRemove("html", !1, !1, !0)) : jqLite = JQLite, angular.element = jqLite, (function(angular) {
|
||||
}), jqLitePatchJQueryRemove("remove", !0, !0, !1), jqLitePatchJQueryRemove("empty", !1, !1, !1), jqLitePatchJQueryRemove("html", !1, !1, !0)) : jqLite = JQLite, angular.element = jqLite, (function(angular1) {
|
||||
extend(angular, {
|
||||
bootstrap: bootstrap,
|
||||
copy: copy,
|
||||
@ -4493,10 +4493,10 @@
|
||||
return {
|
||||
priority: 100,
|
||||
compile: function(tpl, tplAttr) {
|
||||
return CONSTANT_VALUE_REGEXP.test(tplAttr.ngValue) ? function(scope5, elm, attr) {
|
||||
attr.$set("value", scope5.$eval(attr.ngValue));
|
||||
} : function(scope5, elm, attr) {
|
||||
scope5.$watch(attr.ngValue, function(value) {
|
||||
return CONSTANT_VALUE_REGEXP.test(tplAttr.ngValue) ? function(scope, elm, attr) {
|
||||
attr.$set("value", scope.$eval(attr.ngValue));
|
||||
} : function(scope, elm, attr) {
|
||||
scope.$watch(attr.ngValue, function(value) {
|
||||
attr.$set("value", value);
|
||||
});
|
||||
};
|
||||
|
@ -615,10 +615,10 @@
|
||||
});
|
||||
}
|
||||
});
|
||||
var History1 = Backbone.History = function() {
|
||||
var History = Backbone.History = function() {
|
||||
this.handlers = [], _.bindAll(this, "checkUrl"), "undefined" != typeof window && (this.location = window.location, this.history = window.history);
|
||||
}, routeStripper = /^[#\/]|\s+$/g, rootStripper = /^\/+|\/+$/g, isExplorer = /msie [\w.]+/, trailingSlash = /\/$/, pathStripper = /[?#].*$/;
|
||||
History1.started = !1, _.extend(History1.prototype, Events, {
|
||||
History.started = !1, _.extend(History.prototype, Events, {
|
||||
interval: 50,
|
||||
getHash: function(window) {
|
||||
var match = (window || this).location.href.match(/#(.*)$/);
|
||||
@ -633,8 +633,8 @@
|
||||
return fragment.replace(routeStripper, "");
|
||||
},
|
||||
start: function(options) {
|
||||
if (History1.started) throw new Error("Backbone.history has already been started");
|
||||
History1.started = !0, this.options = _.extend({
|
||||
if (History.started) throw new Error("Backbone.history has already been started");
|
||||
History.started = !0, this.options = _.extend({
|
||||
root: "/"
|
||||
}, this.options, options), this.root = this.options.root, this._wantsHashChange = !1 !== this.options.hashChange, this._wantsPushState = !!this.options.pushState, this._hasPushState = !!(this.options.pushState && this.history && this.history.pushState);
|
||||
var fragment = this.getFragment(), docMode = document.documentMode, oldIE = isExplorer.exec(navigator.userAgent.toLowerCase()) && (!docMode || docMode <= 7);
|
||||
@ -648,7 +648,7 @@
|
||||
if (!this.options.silent) return this.loadUrl();
|
||||
},
|
||||
stop: function() {
|
||||
Backbone.$(window).off("popstate", this.checkUrl).off("hashchange", this.checkUrl), clearInterval(this._checkUrlInterval), History1.started = !1;
|
||||
Backbone.$(window).off("popstate", this.checkUrl).off("hashchange", this.checkUrl), clearInterval(this._checkUrlInterval), History.started = !1;
|
||||
},
|
||||
route: function(route, callback) {
|
||||
this.handlers.unshift({
|
||||
@ -667,7 +667,7 @@
|
||||
});
|
||||
},
|
||||
navigate: function(fragment, options) {
|
||||
if (!History1.started) return !1;
|
||||
if (!History.started) return !1;
|
||||
options && !0 !== options || (options = {
|
||||
trigger: !!options
|
||||
});
|
||||
@ -688,7 +688,7 @@
|
||||
location.replace(href + "#" + fragment);
|
||||
} else location.hash = "#" + fragment;
|
||||
}
|
||||
}), Backbone.history = new History1, Model.extend = Collection.extend = Router.extend = View.extend = History1.extend = function(protoProps, staticProps) {
|
||||
}), Backbone.history = new History, Model.extend = Collection.extend = Router.extend = View.extend = History.extend = function(protoProps, staticProps) {
|
||||
var child, parent = this;
|
||||
child = protoProps && _.has(protoProps, "constructor") ? protoProps.constructor : function() {
|
||||
return parent.apply(this, arguments);
|
||||
|
@ -2798,7 +2798,7 @@
|
||||
for(var collection = (tweeners[prop] || []).concat(tweeners["*"]), index = 0, length = collection.length; index < length; index++)if (collection[index].call(animation, prop, value)) return;
|
||||
});
|
||||
}
|
||||
function Animation1(elem, properties, options) {
|
||||
function Animation(elem, properties, options) {
|
||||
var result, stopped, index = 0, length = animationPrefilters.length, deferred = jQuery.Deferred().always(function() {
|
||||
delete tick.elem;
|
||||
}), tick = function() {
|
||||
@ -2866,7 +2866,7 @@
|
||||
function getWindow(elem) {
|
||||
return jQuery.isWindow(elem) ? elem : 9 === elem.nodeType && (elem.defaultView || elem.parentWindow);
|
||||
}
|
||||
jQuery.Animation = jQuery.extend(Animation1, {
|
||||
jQuery.Animation = jQuery.extend(Animation, {
|
||||
tweener: function(props, callback) {
|
||||
jQuery.isFunction(props) ? (callback = props, props = [
|
||||
"*"
|
||||
@ -2920,7 +2920,7 @@
|
||||
},
|
||||
animate: function(prop, speed, easing, callback) {
|
||||
var empty = jQuery.isEmptyObject(prop), optall = jQuery.speed(speed, easing, callback), doAnimation = function() {
|
||||
var anim = Animation1(this, jQuery.extend({
|
||||
var anim = Animation(this, jQuery.extend({
|
||||
}, prop), optall);
|
||||
doAnimation.finish = function() {
|
||||
anim.stop(!0);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -21,7 +21,7 @@
|
||||
constructor = constructor.parent;
|
||||
}
|
||||
return !!item.hasOwnProperty && item instanceof object;
|
||||
}, Function1 = this.Function, enumerables = !0;
|
||||
}, Function = this.Function, enumerables = !0;
|
||||
for(var i in {
|
||||
toString: 1
|
||||
})enumerables = null;
|
||||
@ -33,7 +33,7 @@
|
||||
"toLocaleString",
|
||||
"toString",
|
||||
"constructor"
|
||||
]), Function1.prototype.overloadSetter = function(usePlural) {
|
||||
]), Function.prototype.overloadSetter = function(usePlural) {
|
||||
var self = this;
|
||||
return function(a, b) {
|
||||
if (null == a) return this;
|
||||
@ -43,7 +43,7 @@
|
||||
} else self.call(this, a, b);
|
||||
return this;
|
||||
};
|
||||
}, Function1.prototype.overloadGetter = function(usePlural) {
|
||||
}, Function.prototype.overloadGetter = function(usePlural) {
|
||||
var self = this;
|
||||
return function(a) {
|
||||
var args, result;
|
||||
@ -56,13 +56,13 @@
|
||||
} else result = self.call(this, a);
|
||||
return result;
|
||||
};
|
||||
}, Function1.prototype.extend = (function(key, value) {
|
||||
}, Function.prototype.extend = (function(key, value) {
|
||||
this[key] = value;
|
||||
}).overloadSetter(), Function1.prototype.implement = (function(key, value) {
|
||||
}).overloadSetter(), Function.prototype.implement = (function(key, value) {
|
||||
this.prototype[key] = value;
|
||||
}).overloadSetter();
|
||||
var slice = Array.prototype.slice;
|
||||
Function1.from = function(item) {
|
||||
Function.from = function(item) {
|
||||
return "function" == typeOf(item) ? item : function() {
|
||||
return item;
|
||||
};
|
||||
@ -75,7 +75,7 @@
|
||||
return isFinite(number) ? number : null;
|
||||
}, String.from = function(item) {
|
||||
return item + "";
|
||||
}, Function1.implement({
|
||||
}, Function.implement({
|
||||
hide: function() {
|
||||
return this.$hidden = !0, this;
|
||||
},
|
||||
@ -186,7 +186,7 @@
|
||||
"toFixed",
|
||||
"toLocaleString",
|
||||
"toPrecision"
|
||||
])("Function", Function1, [
|
||||
])("Function", Function, [
|
||||
"apply",
|
||||
"call",
|
||||
"bind"
|
||||
@ -344,7 +344,7 @@
|
||||
var args = Array.slice(arguments);
|
||||
return args.unshift({
|
||||
}), Object.merge.apply(null, args);
|
||||
}, this.$lambda = Function1.from, this.$mixin = Object.merge, this.$random = Number.random, this.$splat = Array.from, this.$time = Date.now, this.$type = function(object) {
|
||||
}, this.$lambda = Function.from, this.$mixin = Object.merge, this.$random = Number.random, this.$splat = Array.from, this.$time = Date.now, this.$type = function(object) {
|
||||
var type = typeOf(object);
|
||||
return "elements" == type ? "array" : "null" != type && type;
|
||||
}, this.$unlink = function(object) {
|
||||
@ -844,7 +844,7 @@ var $try = Function.attempt;
|
||||
var arrayFrom = Array.from;
|
||||
try {
|
||||
arrayFrom(document.html.childNodes);
|
||||
} catch (e) {
|
||||
} catch (e1) {
|
||||
Array.from = function(item) {
|
||||
if ("string" != typeof item && Type.isEnumerable(item) && "array" != typeOf(item)) {
|
||||
for(var i = item.length, array = new Array(i); i--;)array[i] = item[i];
|
||||
@ -913,7 +913,7 @@ var $try = Function.attempt;
|
||||
for(var type = this.type = event.type, target = event.target || event.srcElement; target && 3 == target.nodeType;)target = target.parentNode;
|
||||
if (this.target = document.id(target), 0 == type.indexOf("key")) {
|
||||
var code = this.code = event.which || event.keyCode;
|
||||
this.key = _keys[code] || Object.keyOf(Event1.Keys, code), "keydown" == type && (code > 111 && code < 124 ? this.key = "f" + (code - 111) : code > 95 && code < 106 && (this.key = code - 96)), null == this.key && (this.key = String.fromCharCode(code).toLowerCase());
|
||||
this.key = _keys[code] || Object.keyOf(Event.Keys, code), "keydown" == type && (code > 111 && code < 124 ? this.key = "f" + (code - 111) : code > 95 && code < 106 && (this.key = code - 96)), null == this.key && (this.key = String.fromCharCode(code).toLowerCase());
|
||||
} else if ("click" == type || "dblclick" == type || "contextmenu" == type || "DOMMouseScroll" == type || 0 == type.indexOf("mouse")) {
|
||||
var doc = win.document;
|
||||
if (doc = doc.compatMode && "CSS1Compat" != doc.compatMode ? doc.body : doc.html, this.page = {
|
||||
@ -969,9 +969,9 @@ var $try = Function.attempt;
|
||||
"13": "enter"
|
||||
});
|
||||
})();
|
||||
var Event1 = DOMEvent;
|
||||
Event1.Keys = {
|
||||
}, Event1.Keys = new Hash(Event1.Keys), (function() {
|
||||
var Event = DOMEvent;
|
||||
Event.Keys = {
|
||||
}, Event.Keys = new Hash(Event.Keys), (function() {
|
||||
var Class = this.Class = new Type("Class", function(params) {
|
||||
instanceOf(params, Function) && (params = {
|
||||
initialize: params
|
||||
@ -1146,7 +1146,7 @@ Event1.Keys = {
|
||||
if ((separator || -1 === separatorIndex) && (parsed.expressions[++separatorIndex] = [], combinatorIndex = -1, separator)) return "";
|
||||
if (combinator || combinatorChildren || -1 === combinatorIndex) {
|
||||
combinator = combinator || " ";
|
||||
var test, regexp1, currentSeparator = parsed.expressions[separatorIndex];
|
||||
var test, regexp, currentSeparator = parsed.expressions[separatorIndex];
|
||||
reversed && currentSeparator[combinatorIndex] && (currentSeparator[combinatorIndex].reverseCombinator = reverseCombinator(combinator)), currentSeparator[++combinatorIndex] = {
|
||||
combinator: combinator,
|
||||
tag: "*"
|
||||
@ -1167,16 +1167,16 @@ Event1.Keys = {
|
||||
else if (attributeKey) {
|
||||
switch(attributeKey = attributeKey.replace(reUnescape, ""), attributeValue = (attributeValue || "").replace(reUnescape, ""), attributeOperator){
|
||||
case "^=":
|
||||
regexp1 = new RegExp("^" + escapeRegExp(attributeValue));
|
||||
regexp = new RegExp("^" + escapeRegExp(attributeValue));
|
||||
break;
|
||||
case "$=":
|
||||
regexp1 = new RegExp(escapeRegExp(attributeValue) + "$");
|
||||
regexp = new RegExp(escapeRegExp(attributeValue) + "$");
|
||||
break;
|
||||
case "~=":
|
||||
regexp1 = new RegExp("(^|\\s)" + escapeRegExp(attributeValue) + "(\\s|$)");
|
||||
regexp = new RegExp("(^|\\s)" + escapeRegExp(attributeValue) + "(\\s|$)");
|
||||
break;
|
||||
case "|=":
|
||||
regexp1 = new RegExp("^" + escapeRegExp(attributeValue) + "(-|$)");
|
||||
regexp = new RegExp("^" + escapeRegExp(attributeValue) + "(-|$)");
|
||||
break;
|
||||
case "=":
|
||||
test = function(value) {
|
||||
@ -1201,7 +1201,7 @@ Event1.Keys = {
|
||||
"" == attributeValue && /^[*$^]=$/.test(attributeOperator) && (test = function() {
|
||||
return !1;
|
||||
}), test || (test = function(value) {
|
||||
return value && regexp1.test(value);
|
||||
return value && regexp.test(value);
|
||||
}), currentParsed.attributes || (currentParsed.attributes = []), currentParsed.attributes.push({
|
||||
key: attributeKey,
|
||||
operator: attributeOperator,
|
||||
@ -1256,7 +1256,7 @@ Event1.Keys = {
|
||||
features.brokenStarGEBTN = starSelectsComments || starSelectsClosed;
|
||||
try {
|
||||
testNode.innerHTML = "<a name=\"" + id + "\"></a><b id=\"" + id + "\"></b>", features.idGetsName = document.getElementById(id) === testNode.firstChild;
|
||||
} catch (e) {
|
||||
} catch (e1) {
|
||||
}
|
||||
if (testNode.getElementsByClassName) {
|
||||
try {
|
||||
@ -1265,7 +1265,7 @@ Event1.Keys = {
|
||||
}
|
||||
try {
|
||||
testNode.innerHTML = "<a class=\"a\"></a><a class=\"f b a\"></a>", brokenSecondClassNameGEBCN = 2 != testNode.getElementsByClassName("a").length;
|
||||
} catch (e) {
|
||||
} catch (e2) {
|
||||
}
|
||||
features.brokenGEBCN = cachedGetElementsByClassName || brokenSecondClassNameGEBCN;
|
||||
}
|
||||
@ -1276,29 +1276,29 @@ Event1.Keys = {
|
||||
}
|
||||
try {
|
||||
testNode.innerHTML = "<a class=\"MiX\"></a>", features.brokenMixedCaseQSA = !testNode.querySelectorAll(".MiX").length;
|
||||
} catch (e) {
|
||||
} catch (e2) {
|
||||
}
|
||||
try {
|
||||
testNode.innerHTML = "<select><option selected=\"selected\">a</option></select>", features.brokenCheckedQSA = 0 == testNode.querySelectorAll(":checked").length;
|
||||
} catch (e) {
|
||||
} catch (e3) {
|
||||
}
|
||||
try {
|
||||
testNode.innerHTML = "<a class=\"\"></a>", features.brokenEmptyAttributeQSA = 0 != testNode.querySelectorAll("[class*=\"\"]").length;
|
||||
} catch (e) {
|
||||
} catch (e4) {
|
||||
}
|
||||
}
|
||||
try {
|
||||
testNode.innerHTML = "<form action=\"s\"><input id=\"action\"/></form>", brokenFormAttributeGetter = "s" != testNode.firstChild.getAttribute("action");
|
||||
} catch (e) {
|
||||
} catch (e2) {
|
||||
}
|
||||
if (features.nativeMatchesSelector = root.matchesSelector || root.mozMatchesSelector || root.webkitMatchesSelector, features.nativeMatchesSelector) try {
|
||||
features.nativeMatchesSelector.call(root, ":slick"), features.nativeMatchesSelector = null;
|
||||
} catch (e) {
|
||||
} catch (e3) {
|
||||
}
|
||||
}
|
||||
try {
|
||||
root.slick_expando = 1, delete root.slick_expando, features.getUID = this.getUIDHTML;
|
||||
} catch (e) {
|
||||
} catch (e1) {
|
||||
features.getUID = this.getUIDXML;
|
||||
}
|
||||
testRoot.removeChild(testNode), testNode = selected = testRoot = null, features.getAttribute = features.isHTMLDocument && brokenFormAttributeGetter ? function(node, name) {
|
||||
@ -1724,14 +1724,14 @@ Event1.Keys = {
|
||||
return pseudo ? function(argument) {
|
||||
return pseudo.call(this, argument);
|
||||
} : null;
|
||||
}, Slick.override = function(regexp2, fn) {
|
||||
return local.override(regexp2, fn), this;
|
||||
}, Slick.override = function(regexp, fn) {
|
||||
return local.override(regexp, fn), this;
|
||||
}, Slick.isXML = local.isXML, Slick.uidOf = function(node) {
|
||||
return local.getUIDHTML(node);
|
||||
}, this.Slick || (this.Slick = Slick);
|
||||
}).apply("undefined" != typeof exports ? exports : this);
|
||||
var Element1 = function(tag, props) {
|
||||
var konstructor = Element1.Constructors[tag];
|
||||
var Element = function(tag, props) {
|
||||
var konstructor = Element.Constructors[tag];
|
||||
if (konstructor) return konstructor(props);
|
||||
if ("string" != typeof tag) return document.id(tag).set(props);
|
||||
if (props || (props = {
|
||||
@ -1744,9 +1744,9 @@ var Element1 = function(tag, props) {
|
||||
}
|
||||
return document.newElement(tag, props);
|
||||
};
|
||||
Browser.Element && (Element1.prototype = Browser.Element.prototype, Element1.prototype._fireEvent = function(type, event) {
|
||||
return (fireEvent = Element1.prototype.fireEvent).call(this, type, event);
|
||||
}), new Type("Element", Element1).mirror(function(name) {
|
||||
Browser.Element && (Element.prototype = Browser.Element.prototype, Element.prototype._fireEvent = function(type, event) {
|
||||
return (fireEvent = Element.prototype.fireEvent).call(this, type, event);
|
||||
}), new Type("Element", Element).mirror(function(name) {
|
||||
if (!Array.prototype[name]) {
|
||||
var obj = {
|
||||
};
|
||||
@ -1758,13 +1758,13 @@ Browser.Element && (Element1.prototype = Browser.Element.prototype, Element1.pro
|
||||
return elements ? new Elements(results) : results;
|
||||
}, Elements.implement(obj);
|
||||
}
|
||||
}), Browser.Element || (Element1.parent = Object, Element1.Prototype = {
|
||||
"$constructor": Element1,
|
||||
}), Browser.Element || (Element.parent = Object, Element.Prototype = {
|
||||
"$constructor": Element,
|
||||
"$family": Function.from("element").hide()
|
||||
}, Element1.mirror(function(name, method) {
|
||||
Element1.Prototype[name] = method;
|
||||
})), Element1.Constructors = {
|
||||
}, Element1.Constructors = new Hash;
|
||||
}, Element.mirror(function(name, method) {
|
||||
Element.Prototype[name] = method;
|
||||
})), Element.Constructors = {
|
||||
}, Element.Constructors = new Hash;
|
||||
var IFrame = new Type("IFrame", function() {
|
||||
var iframe, params = Array.link(arguments, {
|
||||
properties: Type.isObject,
|
||||
@ -1782,7 +1782,7 @@ var IFrame = new Type("IFrame", function() {
|
||||
iframe ? iframe.id || iframe.name : "IFrame_" + String.uniqueID()
|
||||
].pick();
|
||||
var onLoad = function() {
|
||||
onload.call((iframe = new Element1(iframe || "iframe", props)).contentWindow);
|
||||
onload.call((iframe = new Element(iframe || "iframe", props)).contentWindow);
|
||||
};
|
||||
return window.frames[props.id] ? onLoad() : iframe.addListener("load", onLoad), iframe;
|
||||
}), Elements = this.Elements = function(nodes) {
|
||||
@ -1870,10 +1870,10 @@ Elements.prototype = {
|
||||
},
|
||||
element: function(el, nocash) {
|
||||
if (Slick.uidOf(el), !nocash && !el.$family && !/^(?:object|embed)$/i.test(el.tagName)) {
|
||||
var fireEvent1 = el.fireEvent;
|
||||
var fireEvent = el.fireEvent;
|
||||
el._fireEvent = function(type, event) {
|
||||
return fireEvent1(type, event);
|
||||
}, Object.append(el, Element1.Prototype);
|
||||
return fireEvent(type, event);
|
||||
}, Object.append(el, Element.Prototype);
|
||||
}
|
||||
return el;
|
||||
},
|
||||
@ -1898,7 +1898,7 @@ Elements.prototype = {
|
||||
}
|
||||
}), [
|
||||
Document,
|
||||
Element1
|
||||
Element
|
||||
].invoke("implement", {
|
||||
getElements: function(expression) {
|
||||
return Slick.search(this, expression, new Elements);
|
||||
@ -1912,7 +1912,7 @@ Elements.prototype = {
|
||||
return Slick.contains(this, element);
|
||||
}
|
||||
};
|
||||
document.contains || Document.implement(contains), document.createElement("div").contains || Element1.implement(contains), Element1.implement("hasChild", function(element) {
|
||||
document.contains || Document.implement(contains), document.createElement("div").contains || Element.implement(contains), Element.implement("hasChild", function(element) {
|
||||
return this !== element && this.contains(element);
|
||||
}), search = Slick.search, find = Slick.find, match = Slick.match, this.Selectors = {
|
||||
}, pseudos = this.Selectors.Pseudo = new Hash(), addSlickPseudos = function() {
|
||||
@ -1934,7 +1934,7 @@ Elements.prototype = {
|
||||
getPrevious: "!~",
|
||||
getParent: "!"
|
||||
}, function(combinator, method) {
|
||||
Element1.implement(method, function(expression) {
|
||||
Element.implement(method, function(expression) {
|
||||
return this.getElement(injectCombinator(expression, combinator));
|
||||
});
|
||||
}), Object.forEach({
|
||||
@ -1944,10 +1944,10 @@ Elements.prototype = {
|
||||
getChildren: ">",
|
||||
getParents: "!"
|
||||
}, function(combinator, method) {
|
||||
Element1.implement(method, function(expression) {
|
||||
Element.implement(method, function(expression) {
|
||||
return this.getElements(injectCombinator(expression, combinator));
|
||||
});
|
||||
}), Element1.implement({
|
||||
}), Element.implement({
|
||||
getFirst: function(expression) {
|
||||
return document.id(Slick.search(this, injectCombinator(expression, ">"))[0]);
|
||||
},
|
||||
@ -2011,7 +2011,7 @@ Elements.prototype = {
|
||||
return inserter(this, document.id(el, !0)), this;
|
||||
}, methods["grab" + where] = function(el) {
|
||||
return inserter(document.id(el, !0), this), this;
|
||||
}, Element1.implement(methods);
|
||||
}, Element.implement(methods);
|
||||
});
|
||||
var propertyGetters = {
|
||||
}, propertySetters = {
|
||||
@ -2095,7 +2095,7 @@ Elements.prototype = {
|
||||
node.type = type, node.value = value;
|
||||
}), input = null;
|
||||
var div, pollutesGetAttribute = ((div = document.createElement("div")).random = "attribute", "attribute" == div.getAttribute("random"));
|
||||
Element1.implement({
|
||||
Element.implement({
|
||||
setProperty: function(name, value) {
|
||||
var setter = propertySetters[name.toLowerCase()];
|
||||
if (setter) setter(this, value);
|
||||
@ -2137,15 +2137,15 @@ Elements.prototype = {
|
||||
return Array.each(arguments, this.removeProperty, this), this;
|
||||
},
|
||||
set: (function(prop, value) {
|
||||
var property = Element1.Properties[prop];
|
||||
var property = Element.Properties[prop];
|
||||
property && property.set ? property.set.call(this, value) : this.setProperty(prop, value);
|
||||
}).overloadSetter(),
|
||||
get: (function(prop) {
|
||||
var property = Element1.Properties[prop];
|
||||
var property = Element.Properties[prop];
|
||||
return property && property.get ? property.get.apply(this) : this.getProperty(prop);
|
||||
}).overloadGetter(),
|
||||
erase: function(prop) {
|
||||
var property = Element1.Properties[prop];
|
||||
var property = Element.Properties[prop];
|
||||
return property && property.erase ? property.erase.apply(this) : this.removeProperty(prop), this;
|
||||
},
|
||||
hasClass: function(className) {
|
||||
@ -2217,13 +2217,13 @@ Elements.prototype = {
|
||||
option: "selected",
|
||||
textarea: "value"
|
||||
};
|
||||
Element1.implement({
|
||||
Element.implement({
|
||||
destroy: function() {
|
||||
var children = clean(this).getElementsByTagName("*");
|
||||
return Array.each(children, clean), Element1.dispose(this), null;
|
||||
return Array.each(children, clean), Element.dispose(this), null;
|
||||
},
|
||||
empty: function() {
|
||||
return Array.from(this.childNodes).each(Element1.dispose), this;
|
||||
return Array.from(this.childNodes).each(Element.dispose), this;
|
||||
},
|
||||
dispose: function() {
|
||||
return this.parentNode ? this.parentNode.removeChild(this) : this;
|
||||
@ -2248,7 +2248,7 @@ Elements.prototype = {
|
||||
return document.id(clone);
|
||||
}
|
||||
}), [
|
||||
Element1,
|
||||
Element,
|
||||
Window,
|
||||
Document
|
||||
].invoke("implement", {
|
||||
@ -2276,8 +2276,8 @@ Elements.prototype = {
|
||||
}
|
||||
}), window.attachEvent && !window.addEventListener && window.addListener("unload", function() {
|
||||
Object.each(collected, clean), window.CollectGarbage && CollectGarbage();
|
||||
}), Element1.Properties = {
|
||||
}, Element1.Properties = new Hash, Element1.Properties.style = {
|
||||
}), Element.Properties = {
|
||||
}, Element.Properties = new Hash, Element.Properties.style = {
|
||||
set: function(style) {
|
||||
this.style.cssText = style;
|
||||
},
|
||||
@ -2287,11 +2287,11 @@ Elements.prototype = {
|
||||
erase: function() {
|
||||
this.style.cssText = "";
|
||||
}
|
||||
}, Element1.Properties.tag = {
|
||||
}, Element.Properties.tag = {
|
||||
get: function() {
|
||||
return this.tagName.toLowerCase();
|
||||
}
|
||||
}, Element1.Properties.html = {
|
||||
}, Element.Properties.html = {
|
||||
set: function(html) {
|
||||
null == html ? html = "" : "array" == typeOf(html) && (html = html.join("")), this.innerHTML = html;
|
||||
},
|
||||
@ -2309,7 +2309,7 @@ Elements.prototype = {
|
||||
}), tr = document.createElement("tr"), html = "<td></td>";
|
||||
tr.innerHTML = html;
|
||||
var supportsTRInnerHTML = tr.innerHTML == html;
|
||||
tr = null, supportsTableInnerHTML && supportsTRInnerHTML && supportsHTML5Elements || (Element1.Properties.html.set = (set = Element1.Properties.html.set, (translations = {
|
||||
tr = null, supportsTableInnerHTML && supportsTRInnerHTML && supportsHTML5Elements || (Element.Properties.html.set = (set = Element.Properties.html.set, (translations = {
|
||||
table: [
|
||||
1,
|
||||
"<table>",
|
||||
@ -2346,7 +2346,7 @@ Elements.prototype = {
|
||||
this.empty().adopt(target.childNodes), supportsHTML5Elements || fragment.removeChild(wrapper), wrapper = null;
|
||||
}));
|
||||
var testForm = document.createElement("form");
|
||||
null.innerHTML = "<select><option>s</option></select>", "s" != null.firstChild.value && (Element1.Properties.value = {
|
||||
null.innerHTML = "<select><option>s</option></select>", "s" != null.firstChild.value && (Element.Properties.value = {
|
||||
set: function(value) {
|
||||
if ("select" != this.get("tag")) return this.setProperty("value", value);
|
||||
for(var options = this.getElements("option"), i = 0; i < options.length; i++){
|
||||
@ -2361,7 +2361,7 @@ Elements.prototype = {
|
||||
var attr = option.getAttributeNode("value");
|
||||
return attr && attr.specified ? option.value : option.get("text");
|
||||
}
|
||||
}), testForm = null, document.createElement("div").getAttributeNode("id") && (Element1.Properties.id = {
|
||||
}), testForm = null, document.createElement("div").getAttributeNode("id") && (Element.Properties.id = {
|
||||
set: function(id) {
|
||||
this.id = this.getAttributeNode("id").value = id;
|
||||
},
|
||||
@ -2376,7 +2376,7 @@ Elements.prototype = {
|
||||
var html = document.html, el = document.createElement("div");
|
||||
null.style.color = "red", null.style.color = null;
|
||||
var doesNotRemoveStyles = "red" == null.style.color;
|
||||
el = null, Element1.Properties.styles = {
|
||||
el = null, Element.Properties.styles = {
|
||||
set: function(styles) {
|
||||
this.setStyles(styles);
|
||||
}
|
||||
@ -2400,16 +2400,16 @@ Elements.prototype = {
|
||||
var opacity = element.retrieve("$opacity");
|
||||
return null == opacity && (opacity = "hidden" == element.style.visibility ? 0 : 1), opacity;
|
||||
}, floatName = null == html.style.cssFloat ? "styleFloat" : "cssFloat";
|
||||
Element1.implement({
|
||||
Element.implement({
|
||||
getComputedStyle: function(property) {
|
||||
if (this.currentStyle) return this.currentStyle[property.camelCase()];
|
||||
var defaultView = Element1.getDocument(this).defaultView, computed = defaultView ? defaultView.getComputedStyle(this, null) : null;
|
||||
var defaultView = Element.getDocument(this).defaultView, computed = defaultView ? defaultView.getComputedStyle(this, null) : null;
|
||||
return computed ? computed.getPropertyValue(property == floatName ? "float" : property.hyphenate()) : null;
|
||||
},
|
||||
setStyle: function(property, value) {
|
||||
if ("opacity" == property) return null != value && (value = parseFloat(value)), setOpacity(this, value), this;
|
||||
if (property = ("float" == property ? floatName : property).camelCase(), "string" != typeOf(value)) {
|
||||
var map = (Element1.Styles[property] || "@").split(" ");
|
||||
var map = (Element.Styles[property] || "@").split(" ");
|
||||
value = Array.from(value).map(function(val, i) {
|
||||
return map[i] ? "number" == typeOf(val) ? map[i].replace("@", Math.round(val)) : val : "";
|
||||
}).join(" ");
|
||||
@ -2421,8 +2421,8 @@ Elements.prototype = {
|
||||
property = ("float" == property ? floatName : property).camelCase();
|
||||
var result = this.style[property];
|
||||
if (!result || "zIndex" == property) {
|
||||
for(var style in result = [], Element1.ShortStyles)if (property == style) {
|
||||
for(var s in Element1.ShortStyles[style])result.push(this.getStyle(s));
|
||||
for(var style in result = [], Element.ShortStyles)if (property == style) {
|
||||
for(var s in Element.ShortStyles[style])result.push(this.getStyle(s));
|
||||
return result.join(" ");
|
||||
}
|
||||
result = this.getComputedStyle(property);
|
||||
@ -2459,7 +2459,7 @@ Elements.prototype = {
|
||||
result[key] = this.getStyle(key);
|
||||
}, this), result;
|
||||
}
|
||||
}), Element1.Styles = {
|
||||
}), Element.Styles = {
|
||||
left: "@px",
|
||||
top: "@px",
|
||||
bottom: "@px",
|
||||
@ -2488,21 +2488,21 @@ Elements.prototype = {
|
||||
fontWeight: "@",
|
||||
textIndent: "@px",
|
||||
opacity: "@"
|
||||
}, Element1.implement({
|
||||
}, Element.implement({
|
||||
setOpacity: function(value) {
|
||||
return setOpacity(this, value), this;
|
||||
},
|
||||
getOpacity: function() {
|
||||
return getOpacity(this);
|
||||
}
|
||||
}), Element1.Properties.opacity = {
|
||||
}), Element.Properties.opacity = {
|
||||
set: function(opacity) {
|
||||
setOpacity(this, opacity), setVisibility(this, opacity);
|
||||
},
|
||||
get: function() {
|
||||
return getOpacity(this);
|
||||
}
|
||||
}, Element1.Styles = new Hash(Element1.Styles), Element1.ShortStyles = {
|
||||
}, Element.Styles = new Hash(Element.Styles), Element.ShortStyles = {
|
||||
margin: {
|
||||
},
|
||||
padding: {
|
||||
@ -2521,7 +2521,7 @@ Elements.prototype = {
|
||||
"Bottom",
|
||||
"Left"
|
||||
].each(function(direction) {
|
||||
var Short = Element1.ShortStyles, All = Element1.Styles;
|
||||
var Short = Element.ShortStyles, All = Element.Styles;
|
||||
[
|
||||
"margin",
|
||||
"padding"
|
||||
@ -2536,12 +2536,12 @@ Elements.prototype = {
|
||||
}, Short.borderWidth[bdw] = Short[bd][bdw] = All[bdw] = "@px", Short.borderStyle[bds] = Short[bd][bds] = All[bds] = "@", Short.borderColor[bdc] = Short[bd][bdc] = All[bdc] = "rgb(@, @, @)";
|
||||
});
|
||||
})(), (function() {
|
||||
if (Element1.Properties.events = {
|
||||
if (Element.Properties.events = {
|
||||
set: function(events) {
|
||||
this.addEvents(events);
|
||||
}
|
||||
}, [
|
||||
Element1,
|
||||
Element,
|
||||
Window,
|
||||
Document
|
||||
].invoke("implement", {
|
||||
@ -2553,13 +2553,13 @@ Elements.prototype = {
|
||||
values: []
|
||||
}), events[type].keys.contains(fn)) return this;
|
||||
events[type].keys.push(fn);
|
||||
var realType = type, custom = Element1.Events[type], condition = fn, self = this;
|
||||
var realType = type, custom = Element.Events[type], condition = fn, self = this;
|
||||
custom && (custom.onAdd && custom.onAdd.call(this, fn, type), custom.condition && (condition = function(event) {
|
||||
return !custom.condition.call(this, event, type) || fn.call(this, event);
|
||||
}), custom.base && (realType = Function.from(custom.base).call(this, type)));
|
||||
var defn = function() {
|
||||
return fn.call(self);
|
||||
}, nativeEvent = Element1.NativeEvents[realType];
|
||||
}, nativeEvent = Element.NativeEvents[realType];
|
||||
return nativeEvent && (2 == nativeEvent && (defn = function(event) {
|
||||
event = new DOMEvent(event, self.getWindow()), !1 === condition.call(self, event) && event.stop();
|
||||
}), this.addListener(realType, defn, arguments[2])), events[type].values.push(defn), this;
|
||||
@ -2571,8 +2571,8 @@ Elements.prototype = {
|
||||
if (-1 == index) return this;
|
||||
var value = list.values[index];
|
||||
delete list.keys[index], delete list.values[index];
|
||||
var custom = Element1.Events[type];
|
||||
return custom && (custom.onRemove && custom.onRemove.call(this, fn, type), custom.base && (type = Function.from(custom.base).call(this, type))), Element1.NativeEvents[type] ? this.removeListener(type, value, arguments[2]) : this;
|
||||
var custom = Element.Events[type];
|
||||
return custom && (custom.onRemove && custom.onRemove.call(this, fn, type), custom.base && (type = Function.from(custom.base).call(this, type))), Element.NativeEvents[type] ? this.removeListener(type, value, arguments[2]) : this;
|
||||
},
|
||||
addEvents: function(events) {
|
||||
for(var event in events)this.addEvent(event, events[event]);
|
||||
@ -2610,7 +2610,7 @@ Elements.prototype = {
|
||||
else for(var eventType in events)this.cloneEvents(from, eventType);
|
||||
return this;
|
||||
}
|
||||
}), Element1.NativeEvents = {
|
||||
}), Element.NativeEvents = {
|
||||
click: 2,
|
||||
dblclick: 2,
|
||||
mouseup: 2,
|
||||
@ -2652,25 +2652,25 @@ Elements.prototype = {
|
||||
error: 1,
|
||||
abort: 1,
|
||||
scroll: 1
|
||||
}, Element1.Events = {
|
||||
}, Element.Events = {
|
||||
mousewheel: {
|
||||
base: Browser.firefox ? "DOMMouseScroll" : "mousewheel"
|
||||
}
|
||||
}, "onmouseenter" in document.documentElement) Element1.NativeEvents.mouseenter = Element1.NativeEvents.mouseleave = 2;
|
||||
}, "onmouseenter" in document.documentElement) Element.NativeEvents.mouseenter = Element.NativeEvents.mouseleave = 2;
|
||||
else {
|
||||
var check = function(event) {
|
||||
var related = event.relatedTarget;
|
||||
return null == related || !!related && related != this && "xul" != related.prefix && "document" != typeOf(this) && !this.contains(related);
|
||||
};
|
||||
Element1.Events.mouseenter = {
|
||||
Element.Events.mouseenter = {
|
||||
base: "mouseover",
|
||||
condition: check
|
||||
}, Element1.Events.mouseleave = {
|
||||
}, Element.Events.mouseleave = {
|
||||
base: "mouseout",
|
||||
condition: check
|
||||
};
|
||||
}
|
||||
window.addEventListener || (Element1.NativeEvents.propertychange = 2, Element1.Events.change = {
|
||||
window.addEventListener || (Element.NativeEvents.propertychange = 2, Element.Events.change = {
|
||||
base: function() {
|
||||
var type = this.type;
|
||||
return "input" == this.get("tag") && ("radio" == type || "checkbox" == type) ? "propertychange" : "change";
|
||||
@ -2678,10 +2678,10 @@ Elements.prototype = {
|
||||
condition: function(event) {
|
||||
return "radio" != this.type || "checked" == event.event.propertyName && this.checked;
|
||||
}
|
||||
}), Element1.Events = new Hash(Element1.Events);
|
||||
}), Element.Events = new Hash(Element.Events);
|
||||
})(), (function() {
|
||||
var eventListenerSupport = !!window.addEventListener;
|
||||
Element1.NativeEvents.focusin = Element1.NativeEvents.focusout = 2;
|
||||
Element.NativeEvents.focusin = Element.NativeEvents.focusout = 2;
|
||||
var bubbleUp = function(self, match, fn, event, target) {
|
||||
for(; target && target != self;){
|
||||
if (match(target, event)) return fn.call(target, event, target);
|
||||
@ -2749,7 +2749,7 @@ Elements.prototype = {
|
||||
change: inputObserver("change"),
|
||||
select: inputObserver("select")
|
||||
});
|
||||
var proto = Element1.prototype, addEvent = proto.addEvent, removeEvent = proto.removeEvent, relay = function(old, method) {
|
||||
var proto = Element.prototype, addEvent = proto.addEvent, removeEvent = proto.removeEvent, relay = function(old, method) {
|
||||
return function(type, fn, useCapture) {
|
||||
if (-1 == type.indexOf(":relay")) return old.call(this, type, fn, useCapture);
|
||||
var parsed = Slick.parse(type).expressions[0][0];
|
||||
@ -2771,7 +2771,7 @@ Elements.prototype = {
|
||||
type = _map.base || _type, match = function(target) {
|
||||
return Slick.match(target, _match);
|
||||
};
|
||||
var elementEvent = Element1.Events[_type];
|
||||
var elementEvent = Element.Events[_type];
|
||||
if (elementEvent && elementEvent.condition) {
|
||||
var __match = match, condition = elementEvent.condition;
|
||||
match = function(target, event) {
|
||||
@ -2806,7 +2806,7 @@ Elements.prototype = {
|
||||
}
|
||||
};
|
||||
[
|
||||
Element1,
|
||||
Element,
|
||||
Window,
|
||||
Document
|
||||
].invoke("implement", {
|
||||
@ -2823,7 +2823,7 @@ Elements.prototype = {
|
||||
}, isOffsetStatic = function(el) {
|
||||
return isOffset(el) || /^(?:table|td|th)$/i.test(el.tagName);
|
||||
};
|
||||
Element1.implement({
|
||||
Element.implement({
|
||||
scrollTo: function(x, y) {
|
||||
return isBody(this) ? this.getWindow().scrollTo(x, y) : (this.scrollLeft = x, this.scrollTop = y), this;
|
||||
},
|
||||
@ -2965,7 +2965,7 @@ Elements.prototype = {
|
||||
};
|
||||
}
|
||||
});
|
||||
var styleString = Element1.getComputedStyle;
|
||||
var styleString = Element.getComputedStyle;
|
||||
function styleNumber(element, style) {
|
||||
return styleString(element, style).toInt() || 0;
|
||||
}
|
||||
@ -2985,12 +2985,12 @@ Elements.prototype = {
|
||||
var doc = element.getDocument();
|
||||
return doc.compatMode && "CSS1Compat" != doc.compatMode ? doc.body : doc.html;
|
||||
}
|
||||
})(), Element1.alias({
|
||||
})(), Element.alias({
|
||||
position: "setPosition"
|
||||
}), [
|
||||
Window,
|
||||
Document,
|
||||
Element1
|
||||
Element
|
||||
].invoke("implement", {
|
||||
getHeight: function() {
|
||||
return this.getSize().y;
|
||||
@ -3181,8 +3181,8 @@ Elements.prototype = {
|
||||
var selectorText = rule.selectorText ? rule.selectorText.replace(/^\w+/, function(m) {
|
||||
return m.toLowerCase();
|
||||
}) : null;
|
||||
selectorText && selectorTest.test(selectorText) && Object.each(Element1.Styles, function(value, style) {
|
||||
rule.style[style] && !Element1.ShortStyles[style] && (value = String(rule.style[style]), to[style] = /^rgb/.test(value) ? value.rgbToHex() : value);
|
||||
selectorText && selectorTest.test(selectorText) && Object.each(Element.Styles, function(value, style) {
|
||||
rule.style[style] && !Element.ShortStyles[style] && (value = String(rule.style[style]), to[style] = /^rgb/.test(value) ? value.rgbToHex() : value);
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -3239,7 +3239,7 @@ Elements.prototype = {
|
||||
var parsed = this.prepare(this.element, this.property, args);
|
||||
return this.parent(parsed.from, parsed.to);
|
||||
}
|
||||
}), Element1.Properties.tween = {
|
||||
}), Element.Properties.tween = {
|
||||
set: function(options) {
|
||||
return this.get("tween").cancel().setOptions(options), this;
|
||||
},
|
||||
@ -3249,7 +3249,7 @@ Elements.prototype = {
|
||||
link: "cancel"
|
||||
}), this.store("tween", tween)), tween;
|
||||
}
|
||||
}, Element1.implement({
|
||||
}, Element.implement({
|
||||
tween: function(property, from, to) {
|
||||
return this.get("tween").start(property, from, to), this;
|
||||
},
|
||||
@ -3317,7 +3317,7 @@ Elements.prototype = {
|
||||
}
|
||||
return this.parent(from, to);
|
||||
}
|
||||
}), Element1.Properties.morph = {
|
||||
}), Element.Properties.morph = {
|
||||
set: function(options) {
|
||||
return this.get("morph").cancel().setOptions(options), this;
|
||||
},
|
||||
@ -3327,7 +3327,7 @@ Elements.prototype = {
|
||||
link: "cancel"
|
||||
}), this.store("morph", morph)), morph;
|
||||
}
|
||||
}, Element1.implement({
|
||||
}, Element.implement({
|
||||
morph: function(props) {
|
||||
return this.get("morph").start(props), this;
|
||||
}
|
||||
@ -3396,7 +3396,7 @@ Elements.prototype = {
|
||||
});
|
||||
}), (function() {
|
||||
var empty = function() {
|
||||
}, progressSupport = "onprogress" in new Browser.Request, Request1 = this.Request = new Class({
|
||||
}, progressSupport = "onprogress" in new Browser.Request, Request = this.Request = new Class({
|
||||
Implements: [
|
||||
Chain,
|
||||
Events,
|
||||
@ -3567,20 +3567,20 @@ Elements.prototype = {
|
||||
};
|
||||
return null != data && (object.data = data), this.send(object);
|
||||
};
|
||||
}), Request1.implement(methods), Element1.Properties.send = {
|
||||
}), Request.implement(methods), Element.Properties.send = {
|
||||
set: function(options) {
|
||||
return this.get("send").cancel().setOptions(options), this;
|
||||
},
|
||||
get: function() {
|
||||
var send = this.retrieve("send");
|
||||
return send || (send = new Request1({
|
||||
return send || (send = new Request({
|
||||
data: this,
|
||||
link: "cancel",
|
||||
method: this.get("method") || "post",
|
||||
url: this.get("action")
|
||||
}), this.store("send", send)), send;
|
||||
}
|
||||
}, Element1.implement({
|
||||
}, Element.implement({
|
||||
send: function(url) {
|
||||
var sender = this.get("send");
|
||||
return sender.send({
|
||||
@ -3607,7 +3607,7 @@ Elements.prototype = {
|
||||
});
|
||||
var match = response.html.match(/<body[^>]*>([\s\S]*?)<\/body>/i);
|
||||
match && (response.html = match[1]);
|
||||
var temp = new Element1("div").set("html", response.html);
|
||||
var temp = new Element("div").set("html", response.html);
|
||||
if (response.tree = temp.childNodes, response.elements = temp.getElements(options.filter || "*"), options.filter && (response.tree = response.elements), options.update) {
|
||||
var update = document.id(options.update).empty();
|
||||
options.filter ? update.adopt(response.elements) : update.set("html", response.html);
|
||||
@ -3617,7 +3617,7 @@ Elements.prototype = {
|
||||
}
|
||||
options.evalScripts && Browser.exec(response.javascript), this.onSuccess(response.tree, response.elements, response.html, response.javascript);
|
||||
}
|
||||
}), Element1.Properties.load = {
|
||||
}), Element.Properties.load = {
|
||||
set: function(options) {
|
||||
return this.get("load").cancel().setOptions(options), this;
|
||||
},
|
||||
@ -3630,7 +3630,7 @@ Elements.prototype = {
|
||||
method: "get"
|
||||
}), this.store("load", load)), load;
|
||||
}
|
||||
}, Element1.implement({
|
||||
}, Element.implement({
|
||||
load: function() {
|
||||
return this.get("load").send(Array.link(arguments, {
|
||||
data: Type.isObject,
|
||||
@ -3766,17 +3766,17 @@ Cookie.write = function(key, value, options) {
|
||||
testElement.doScroll && !doScrollWorks() && (checks.push(doScrollWorks), shouldPoll = !0), document.readyState && checks.push(function() {
|
||||
var state = document.readyState;
|
||||
return "loaded" == state || "complete" == state;
|
||||
}), "onreadystatechange" in document ? document.addListener("readystatechange", check) : shouldPoll = !0, shouldPoll && poll(), Element1.Events.domready = {
|
||||
}), "onreadystatechange" in document ? document.addListener("readystatechange", check) : shouldPoll = !0, shouldPoll && poll(), Element.Events.domready = {
|
||||
onAdd: function(fn) {
|
||||
ready && fn.call(this);
|
||||
}
|
||||
}, Element1.Events.load = {
|
||||
}, Element.Events.load = {
|
||||
base: "load",
|
||||
onAdd: function(fn) {
|
||||
loaded && this == window && fn.call(this);
|
||||
},
|
||||
condition: function() {
|
||||
return this == window && (domready(), delete Element1.Events.load), !0;
|
||||
return this == window && (domready(), delete Element.Events.load), !0;
|
||||
}
|
||||
}, window.addEvent("load", function() {
|
||||
loaded = !0;
|
||||
@ -3823,7 +3823,7 @@ Cookie.write = function(key, value, options) {
|
||||
var build = "<object id=\"" + id + "\"";
|
||||
for(var property in properties)build += " " + property + "=\"" + properties[property] + "\"";
|
||||
for(var param in build += ">", params)params[param] && (build += "<param name=\"" + param + "\" value=\"" + params[param] + "\" />");
|
||||
build += "</object>", this.object = (container ? container.empty() : new Element1("div")).set("html", build).firstChild;
|
||||
build += "</object>", this.object = (container ? container.empty() : new Element("div")).set("html", build).firstChild;
|
||||
},
|
||||
replaces: function(element) {
|
||||
return (element = document.id(element, !0)).parentNode.replaceChild(this.toElement(), element), this;
|
||||
|
@ -9331,9 +9331,9 @@
|
||||
var threadID = computeThreadID(root, lanes);
|
||||
try {
|
||||
subscriber.onWorkStarted(interactions, threadID);
|
||||
} catch (error1) {
|
||||
} catch (error) {
|
||||
scheduleCallback(99, function() {
|
||||
throw error1;
|
||||
throw error;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -9505,7 +9505,7 @@
|
||||
]), new Set([
|
||||
nonExtensibleObject
|
||||
]);
|
||||
} catch (e) {
|
||||
} catch (e1) {
|
||||
hasBadMapPolyfill = !0;
|
||||
}
|
||||
var debugCounter = 1;
|
||||
|
@ -1,6 +1,6 @@
|
||||
var a = 1;
|
||||
!function() {
|
||||
var a;
|
||||
var a1;
|
||||
a = 3;
|
||||
console.log("PASS");
|
||||
}();
|
||||
|
@ -1,36 +1,44 @@
|
||||
{
|
||||
const [aa, [bb, cc]] = dd;
|
||||
}
|
||||
{
|
||||
}{
|
||||
let [aa, [bb, cc]] = dd;
|
||||
}
|
||||
var [aa, [bb, cc]] = dd;
|
||||
}var [aa, [bb, cc]] = dd;
|
||||
[aa, [bb, cc]] = dd;
|
||||
{
|
||||
const {
|
||||
aa: aa,
|
||||
bb: { cc: cc, dd: dd },
|
||||
} = { aa: 1, bb: { cc: 2, dd: 3 } };
|
||||
}
|
||||
{
|
||||
let {
|
||||
aa: aa,
|
||||
bb: { cc: cc, dd: dd },
|
||||
} = { aa: 1, bb: { cc: 2, dd: 3 } };
|
||||
}
|
||||
var {
|
||||
aa: aa,
|
||||
bb: { cc: cc, dd: dd },
|
||||
} = { aa: 1, bb: { cc: 2, dd: 3 } };
|
||||
({
|
||||
aa: aa,
|
||||
bb: { cc: cc, dd: dd },
|
||||
} = { aa: 1, bb: { cc: 2, dd: 3 } });
|
||||
const [{ a: a }, b] = c;
|
||||
let [{ d: d }, e] = f;
|
||||
var [{ g: g }, h] = i;
|
||||
[{ a: a }, b] = c;
|
||||
for (const [x, y] in pairs);
|
||||
for (let [x, y] in pairs);
|
||||
for (var [x, y] in pairs);
|
||||
for ([x, y] in pairs);
|
||||
const { aa: aa , bb: { cc: cc , dd: dd } , } = {
|
||||
aa: 1,
|
||||
bb: {
|
||||
cc: 2,
|
||||
dd: 3
|
||||
}
|
||||
};
|
||||
}{
|
||||
let { aa: aa , bb: { cc: cc , dd: dd } , } = {
|
||||
aa: 1,
|
||||
bb: {
|
||||
cc: 2,
|
||||
dd: 3
|
||||
}
|
||||
};
|
||||
}var { aa: aa , bb: { cc: cc , dd: dd } , } = {
|
||||
aa: 1,
|
||||
bb: {
|
||||
cc: 2,
|
||||
dd: 3
|
||||
}
|
||||
};
|
||||
({ aa: aa , bb: { cc: cc , dd: dd } , } = {
|
||||
aa: 1,
|
||||
bb: {
|
||||
cc: 2,
|
||||
dd: 3
|
||||
}
|
||||
});
|
||||
const [{ a: a }, b] = c;
|
||||
let [{ d: d }, e] = f;
|
||||
var [{ g: g }, h] = i;
|
||||
[{ a: a }, b] = c;
|
||||
for(const [x, y] in pairs);
|
||||
for(let [x1, y1] in pairs);
|
||||
for(var [x2, y2] in pairs);
|
||||
for([x2, y2] in pairs);
|
||||
|
@ -1,8 +1,8 @@
|
||||
!(function (a) {
|
||||
!function(a) {
|
||||
try {
|
||||
throw 0;
|
||||
} catch (NaN1) {
|
||||
} catch (NaN) {
|
||||
a = NaN;
|
||||
}
|
||||
console.log(a);
|
||||
})();
|
||||
}();
|
||||
|
@ -1,8 +1,8 @@
|
||||
!(function (a) {
|
||||
!function(a) {
|
||||
try {
|
||||
throw 0;
|
||||
} catch (Infinity1) {
|
||||
} catch (Infinity) {
|
||||
a = 1 / 0;
|
||||
}
|
||||
console.log(a);
|
||||
})();
|
||||
}();
|
||||
|
@ -1,2 +1,2 @@
|
||||
for (const x of y);
|
||||
for (const x in y);
|
||||
for(const x1 in y);
|
||||
|
@ -1,20 +1,20 @@
|
||||
var tokenCodes = {
|
||||
get instanceof() {
|
||||
get instanceof () {
|
||||
return test0;
|
||||
},
|
||||
set instanceof(value) {
|
||||
set instanceof (value){
|
||||
test0 = value;
|
||||
},
|
||||
set typeof(value) {
|
||||
test1 = value;
|
||||
set typeof (value1){
|
||||
test1 = value1;
|
||||
},
|
||||
get typeof() {
|
||||
get typeof () {
|
||||
return test1;
|
||||
},
|
||||
set else(value) {
|
||||
test2 = value;
|
||||
set else (value2){
|
||||
test2 = value2;
|
||||
},
|
||||
get else() {
|
||||
get else () {
|
||||
return test2;
|
||||
},
|
||||
}
|
||||
};
|
||||
|
@ -1,6 +1,6 @@
|
||||
try {
|
||||
throw "FAIL1";
|
||||
} catch (a) {
|
||||
var a = "FAIL2";
|
||||
} catch (a1) {
|
||||
var a1 = "FAIL2";
|
||||
}
|
||||
console.log(a);
|
||||
|
@ -1,6 +1,6 @@
|
||||
try {
|
||||
throw "FAIL1";
|
||||
} catch (a) {
|
||||
var a = "FAIL2";
|
||||
} catch (a1) {
|
||||
var a1 = "FAIL2";
|
||||
}
|
||||
console.log(a);
|
||||
|
@ -1,6 +1,6 @@
|
||||
try {
|
||||
throw "FAIL1";
|
||||
} catch (a) {
|
||||
var a = "FAIL2";
|
||||
} catch (a1) {
|
||||
var a1 = "FAIL2";
|
||||
}
|
||||
console.log(a);
|
||||
|
@ -1,3 +1,3 @@
|
||||
var Infinity1, NaN1;
|
||||
Infinity1.toString();
|
||||
NaN1.toString();
|
||||
var Infinity, NaN;
|
||||
Infinity.toString();
|
||||
NaN.toString();
|
||||
|
@ -1,3 +1,3 @@
|
||||
var Infinity1, NaN1;
|
||||
var Infinity, NaN;
|
||||
(1 / 0).toString();
|
||||
NaN.toString();
|
||||
|
@ -1,11 +1,2 @@
|
||||
var NaN1;
|
||||
console.log(
|
||||
null,
|
||||
void 0,
|
||||
1 / 0,
|
||||
NaN1,
|
||||
NaN,
|
||||
(1 / 0).toString(),
|
||||
NaN1.toString(),
|
||||
NaN.toString()
|
||||
);
|
||||
var NaN;
|
||||
console.log(null, void 0, 1 / 0, NaN, NaN, (1 / 0).toString(), NaN.toString(), NaN.toString());
|
||||
|
@ -1,11 +1,2 @@
|
||||
var NaN1;
|
||||
console.log(
|
||||
null,
|
||||
void 0,
|
||||
1 / 0,
|
||||
NaN1,
|
||||
NaN,
|
||||
(1 / 0).toString(),
|
||||
NaN1.toString(),
|
||||
NaN.toString()
|
||||
);
|
||||
var NaN;
|
||||
console.log(null, void 0, 1 / 0, NaN, NaN, (1 / 0).toString(), NaN.toString(), NaN.toString());
|
||||
|
@ -2,38 +2,44 @@ var get = "bar";
|
||||
var a = {
|
||||
get: get,
|
||||
set: "foo",
|
||||
get bar() {
|
||||
get bar () {
|
||||
return this.get;
|
||||
},
|
||||
get 5() {
|
||||
get 5 () {
|
||||
return "five";
|
||||
},
|
||||
get 3925() {
|
||||
get 3925 () {
|
||||
return "f five five";
|
||||
},
|
||||
get five() {
|
||||
get five () {
|
||||
return 5;
|
||||
},
|
||||
set one(value) {
|
||||
set one (value){
|
||||
this._one = value;
|
||||
},
|
||||
set 9(value) {
|
||||
this._nine = value;
|
||||
set 9 (value1){
|
||||
this._nine = value1;
|
||||
},
|
||||
set 10(value) {
|
||||
this._ten = value;
|
||||
},
|
||||
set eleven(value) {
|
||||
this._eleven = value;
|
||||
set 10 (value2){
|
||||
this._ten = value2;
|
||||
},
|
||||
set eleven (value3){
|
||||
this._eleven = value3;
|
||||
}
|
||||
};
|
||||
var b = {
|
||||
get() {
|
||||
get () {
|
||||
return "gift";
|
||||
},
|
||||
set: function (code) {
|
||||
set: function(code) {
|
||||
return "Storing code " + code;
|
||||
},
|
||||
}
|
||||
};
|
||||
var c = {
|
||||
["get"]: "foo",
|
||||
["set"]: "bar"
|
||||
};
|
||||
var d = {
|
||||
get: "foo",
|
||||
set: "bar"
|
||||
};
|
||||
var c = { ["get"]: "foo", ["set"]: "bar" };
|
||||
var d = { get: "foo", set: "bar" };
|
||||
|
@ -1,16 +1,18 @@
|
||||
var obj = {
|
||||
a() {},
|
||||
b() {},
|
||||
get c() {
|
||||
a () {
|
||||
},
|
||||
b () {
|
||||
},
|
||||
get c () {
|
||||
return "c";
|
||||
},
|
||||
get d() {
|
||||
get d () {
|
||||
return "d";
|
||||
},
|
||||
set e(a) {
|
||||
set e (a){
|
||||
doSomething(a);
|
||||
},
|
||||
set f(a) {
|
||||
set f (a1){
|
||||
doSomething(b);
|
||||
},
|
||||
}
|
||||
};
|
||||
|
@ -1,23 +1,23 @@
|
||||
var foo = {
|
||||
"\0": "foo",
|
||||
get "\0"() {
|
||||
"\x00\x01": "foo",
|
||||
get "\x00\x01" () {
|
||||
return "bar";
|
||||
},
|
||||
set "\0"(foo) {
|
||||
save(foo);
|
||||
set "\x00\x01" (foo1){
|
||||
save(foo1);
|
||||
},
|
||||
*"\0"() {
|
||||
*"\x00\x01" () {
|
||||
return "foobar";
|
||||
},
|
||||
}
|
||||
};
|
||||
class bar {
|
||||
get "\0"() {
|
||||
get "\x00\x01"() {
|
||||
return "bar";
|
||||
}
|
||||
set "\0"(foo) {
|
||||
set "\x00\x01"(foo) {
|
||||
save(foo);
|
||||
}
|
||||
*"\0"() {
|
||||
*"\x00\x01"() {
|
||||
return "foobar";
|
||||
}
|
||||
}
|
||||
|
@ -1,23 +1,23 @@
|
||||
var foo = {
|
||||
"\0\x01": "foo",
|
||||
get "\0\x01"() {
|
||||
"\x00\x01": "foo",
|
||||
get "\x00\x01" () {
|
||||
return "bar";
|
||||
},
|
||||
set "\0\x01"(foo) {
|
||||
save(foo);
|
||||
set "\x00\x01" (foo1){
|
||||
save(foo1);
|
||||
},
|
||||
*"\0\x01"() {
|
||||
*"\x00\x01" () {
|
||||
return "foobar";
|
||||
},
|
||||
}
|
||||
};
|
||||
class bar {
|
||||
get "\0\x01"() {
|
||||
get "\x00\x01"() {
|
||||
return "bar";
|
||||
}
|
||||
set "\0\x01"(foo) {
|
||||
set "\x00\x01"(foo) {
|
||||
save(foo);
|
||||
}
|
||||
*"\0\x01"() {
|
||||
*"\x00\x01"() {
|
||||
return "foobar";
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
try {
|
||||
throw "FAIL1";
|
||||
} catch (a) {
|
||||
var a = "FAIL2";
|
||||
} catch (a1) {
|
||||
var a1 = "FAIL2";
|
||||
}
|
||||
console.log(a);
|
||||
|
@ -1,6 +1,6 @@
|
||||
try {
|
||||
throw "FAIL1";
|
||||
} catch (a) {
|
||||
var a = "FAIL2";
|
||||
} catch (a1) {
|
||||
var a1 = "FAIL2";
|
||||
}
|
||||
console.log(a);
|
||||
|
@ -1,6 +1,6 @@
|
||||
try {
|
||||
throw "FAIL1";
|
||||
} catch (a) {
|
||||
var a = "FAIL2";
|
||||
} catch (a1) {
|
||||
var a1 = "FAIL2";
|
||||
}
|
||||
console.log(a);
|
||||
|
@ -6,7 +6,7 @@ edition = "2018"
|
||||
license = "Apache-2.0/MIT"
|
||||
name = "swc_ecma_transforms_base"
|
||||
repository = "https://github.com/swc-project/swc.git"
|
||||
version = "0.30.0"
|
||||
version = "0.30.1"
|
||||
|
||||
[dependencies]
|
||||
fxhash = "0.2.1"
|
||||
|
@ -1,6 +1,6 @@
|
||||
use self::ops::{Operations, Operator};
|
||||
use crate::{
|
||||
native::{is_native, is_native_word},
|
||||
native::is_native_word,
|
||||
scope::{IdentType, ScopeKind},
|
||||
};
|
||||
use fxhash::{FxHashMap, FxHashSet};
|
||||
@ -44,7 +44,7 @@ struct Hygiene<'a> {
|
||||
type Contexts = SmallVec<[SyntaxContext; 32]>;
|
||||
|
||||
impl<'a> Hygiene<'a> {
|
||||
fn add_declared_ref(&mut self, ident: Ident) {
|
||||
fn add_decl(&mut self, ident: Ident) {
|
||||
let ctxt = ident.span.ctxt();
|
||||
|
||||
if cfg!(debug_assertions) && LOG {
|
||||
@ -56,24 +56,37 @@ impl<'a> Hygiene<'a> {
|
||||
);
|
||||
}
|
||||
|
||||
let can_declare_without_renaming =
|
||||
self.current.can_declare(&ident.sym.to_boxed_str(), ctxt);
|
||||
let sym = self.current.change_symbol(ident.sym, ctxt);
|
||||
|
||||
if cfg!(debug_assertions) && LOG {
|
||||
eprintln!("Changed symbol to {}{:?} ", sym, ctxt);
|
||||
eprintln!("\tChanged symbol to {}{:?} ", sym, ctxt);
|
||||
}
|
||||
|
||||
self.current
|
||||
.declared_symbols
|
||||
.borrow_mut()
|
||||
.entry(sym.to_boxed_str())
|
||||
.or_default()
|
||||
.push(ctxt);
|
||||
{
|
||||
self.current
|
||||
.declared_symbols
|
||||
.borrow_mut()
|
||||
.entry(sym.to_boxed_str())
|
||||
.or_default()
|
||||
.push(ctxt);
|
||||
}
|
||||
|
||||
if can_declare_without_renaming {
|
||||
// skip if previous symbol is declared on the same level.
|
||||
return;
|
||||
{
|
||||
let mut used = self.current.used.borrow_mut();
|
||||
let e = used.entry(sym.to_boxed_str()).or_default();
|
||||
|
||||
if !e.contains(&ctxt) {
|
||||
e.push(ctxt);
|
||||
}
|
||||
|
||||
if e.len() <= 1 {
|
||||
return;
|
||||
}
|
||||
|
||||
// Preserve first one.
|
||||
if e[0] == ctxt {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if cfg!(debug_assertions) && LOG {
|
||||
@ -94,14 +107,22 @@ impl<'a> Hygiene<'a> {
|
||||
|
||||
let ctxt = ident.span.ctxt();
|
||||
|
||||
// Commented out because of https://github.com/swc-project/swc/issues/962
|
||||
{
|
||||
let mut used = self.current.used.borrow_mut();
|
||||
let e = used.entry(ident.sym.to_boxed_str()).or_default();
|
||||
|
||||
// self.current
|
||||
// .declared_symbols
|
||||
// .borrow_mut()
|
||||
// .entry(ident.sym.clone())
|
||||
// .or_insert_with(Vec::new)
|
||||
// .push(ctxt);
|
||||
if !e.contains(&ctxt) {
|
||||
e.push(ctxt);
|
||||
}
|
||||
|
||||
if e.len() <= 1 {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if cfg!(debug_assertions) && LOG {
|
||||
eprintln!("Renaming from reference");
|
||||
}
|
||||
|
||||
// We rename declaration instead of usage
|
||||
let conflicts = self.current.conflicts(ident.sym.clone(), ctxt);
|
||||
@ -264,12 +285,14 @@ impl<'a> Hygiene<'a> {
|
||||
}
|
||||
|
||||
impl<'a> Hygiene<'a> {
|
||||
fn visit_mut_fn(&mut self, ident: Option<Ident>, node: &mut Function) {
|
||||
match ident {
|
||||
Some(ident) => {
|
||||
self.add_declared_ref(ident);
|
||||
fn visit_mut_fn(&mut self, ident: &mut Option<Ident>, node: &mut Function, is_decl: bool) {
|
||||
if is_decl {
|
||||
match ident.clone() {
|
||||
Some(ident) => {
|
||||
self.add_decl(ident.clone());
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
let mut folder = Hygiene {
|
||||
@ -279,6 +302,15 @@ impl<'a> Hygiene<'a> {
|
||||
var_kind: None,
|
||||
};
|
||||
|
||||
if !is_decl {
|
||||
match ident {
|
||||
Some(ident) => {
|
||||
folder.add_decl(ident.clone());
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
folder.ident_type = IdentType::Ref;
|
||||
node.decorators.visit_mut_with(&mut folder);
|
||||
|
||||
@ -290,7 +322,8 @@ impl<'a> Hygiene<'a> {
|
||||
.as_mut()
|
||||
.map(|stmt| stmt.visit_mut_children_with(&mut folder));
|
||||
|
||||
folder.apply_ops(node)
|
||||
folder.apply_ops(ident);
|
||||
folder.apply_ops(node);
|
||||
}
|
||||
}
|
||||
|
||||
@ -302,6 +335,8 @@ struct Scope<'a> {
|
||||
/// Kind of the scope.
|
||||
pub kind: ScopeKind,
|
||||
|
||||
pub used: RefCell<FxHashMap<Box<str>, Vec<SyntaxContext>>>,
|
||||
|
||||
/// All references declared in this scope
|
||||
pub declared_symbols: RefCell<FxHashMap<Box<str>, Vec<SyntaxContext>>>,
|
||||
|
||||
@ -331,6 +366,7 @@ impl<'a> Scope<'a> {
|
||||
// children: Default::default(),
|
||||
ops: Default::default(),
|
||||
renamed: Default::default(),
|
||||
used: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -378,32 +414,6 @@ impl<'a> Scope<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
fn can_declare(&self, sym: &Box<str>, ctxt: SyntaxContext) -> bool {
|
||||
match self.parent {
|
||||
None => {}
|
||||
Some(parent) => {
|
||||
if !parent.can_declare(sym, ctxt) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if is_native(&sym) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if self.renamed.contains(&(&**sym).into()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if let Some(ctxts) = self.declared_symbols.borrow().get(sym) {
|
||||
ctxts.contains(&ctxt)
|
||||
} else {
|
||||
// No variable named `sym` is declared
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns all **conflicting** contexts.
|
||||
///
|
||||
/// It other words, all `SyntaxContext`s with same `sym` will be returned,
|
||||
@ -449,7 +459,7 @@ impl<'a> Scope<'a> {
|
||||
while let Some(scope) = cur {
|
||||
if let Some(to) = scope.ops.borrow().rename.get(&(sym.clone(), ctxt)) {
|
||||
if cfg!(debug_assertions) && LOG {
|
||||
eprintln!("Changing symbol: {}{:?} -> {}", sym, ctxt, to);
|
||||
eprintln!("\tChanging symbol: {}{:?} -> {}", sym, ctxt, to);
|
||||
}
|
||||
sym = to.clone()
|
||||
}
|
||||
@ -583,29 +593,6 @@ impl<'a> VisitMut for Hygiene<'a> {
|
||||
|
||||
track_ident_mut!();
|
||||
|
||||
fn visit_mut_class_decl(&mut self, n: &mut ClassDecl) {
|
||||
let old = self.ident_type;
|
||||
self.ident_type = IdentType::Binding;
|
||||
n.ident.visit_mut_with(self);
|
||||
self.ident_type = old;
|
||||
|
||||
n.class.visit_mut_with(self);
|
||||
}
|
||||
|
||||
fn visit_mut_setter_prop(&mut self, f: &mut SetterProp) {
|
||||
let old = self.ident_type;
|
||||
self.ident_type = IdentType::Ref;
|
||||
f.key.visit_mut_with(self);
|
||||
self.ident_type = old;
|
||||
|
||||
let old = self.ident_type;
|
||||
self.ident_type = IdentType::Binding;
|
||||
f.param.visit_mut_with(self);
|
||||
self.ident_type = old;
|
||||
|
||||
f.body.visit_mut_with(self);
|
||||
}
|
||||
|
||||
fn visit_mut_arrow_expr(&mut self, node: &mut ArrowExpr) {
|
||||
let mut folder = Hygiene {
|
||||
config: self.config.clone(),
|
||||
@ -636,14 +623,15 @@ impl<'a> VisitMut for Hygiene<'a> {
|
||||
}
|
||||
|
||||
fn visit_mut_catch_clause(&mut self, c: &mut CatchClause) {
|
||||
self.ident_type = IdentType::Binding;
|
||||
c.param.visit_mut_with(self);
|
||||
|
||||
let mut folder = Hygiene {
|
||||
config: self.config.clone(),
|
||||
current: Scope::new(ScopeKind::Fn, Some(&self.current)),
|
||||
ident_type: IdentType::Ref,
|
||||
var_kind: None,
|
||||
};
|
||||
folder.ident_type = IdentType::Binding;
|
||||
c.param.visit_mut_with(&mut folder);
|
||||
folder.ident_type = IdentType::Ref;
|
||||
|
||||
c.body.visit_mut_with(&mut folder);
|
||||
@ -651,6 +639,15 @@ impl<'a> VisitMut for Hygiene<'a> {
|
||||
folder.apply_ops(c)
|
||||
}
|
||||
|
||||
fn visit_mut_class_decl(&mut self, n: &mut ClassDecl) {
|
||||
let old = self.ident_type;
|
||||
self.ident_type = IdentType::Binding;
|
||||
n.ident.visit_mut_with(self);
|
||||
self.ident_type = old;
|
||||
|
||||
n.class.visit_mut_with(self);
|
||||
}
|
||||
|
||||
fn visit_mut_class_expr(&mut self, n: &mut ClassExpr) {
|
||||
if let Some(ident) = &mut n.ident {
|
||||
if let Some(expr) = self.keep_class_name(ident, &mut n.class) {
|
||||
@ -734,14 +731,6 @@ impl<'a> VisitMut for Hygiene<'a> {
|
||||
self.ident_type = IdentType::Ref;
|
||||
match node {
|
||||
Expr::Ident(..) => node.visit_mut_children_with(self),
|
||||
Expr::Member(e) => {
|
||||
if e.computed {
|
||||
e.obj.visit_mut_with(self);
|
||||
e.prop.visit_mut_with(self);
|
||||
} else {
|
||||
e.obj.visit_mut_with(self)
|
||||
}
|
||||
}
|
||||
|
||||
Expr::This(..) => {}
|
||||
|
||||
@ -752,11 +741,15 @@ impl<'a> VisitMut for Hygiene<'a> {
|
||||
}
|
||||
|
||||
fn visit_mut_fn_decl(&mut self, node: &mut FnDecl) {
|
||||
self.visit_mut_fn(Some(node.ident.clone()), &mut node.function);
|
||||
let mut new_id = Some(node.ident.clone());
|
||||
self.visit_mut_fn(&mut new_id, &mut node.function, true);
|
||||
node.ident = new_id.unwrap();
|
||||
}
|
||||
|
||||
fn visit_mut_fn_expr(&mut self, node: &mut FnExpr) {
|
||||
self.visit_mut_fn(node.ident.clone(), &mut node.function);
|
||||
let mut new_id = node.ident.clone();
|
||||
self.visit_mut_fn(&mut new_id, &mut node.function, false);
|
||||
node.ident = new_id;
|
||||
}
|
||||
|
||||
/// Invoked for `IdentifierReference` / `BindingIdentifier`
|
||||
@ -766,7 +759,7 @@ impl<'a> VisitMut for Hygiene<'a> {
|
||||
}
|
||||
|
||||
match self.ident_type {
|
||||
IdentType::Binding => self.add_declared_ref(i.clone()),
|
||||
IdentType::Binding => self.add_decl(i.clone()),
|
||||
IdentType::Ref => {
|
||||
// Special cases
|
||||
if is_native_word(&i.sym) {
|
||||
@ -782,26 +775,36 @@ impl<'a> VisitMut for Hygiene<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_mut_member_expr(&mut self, e: &mut MemberExpr) {
|
||||
e.obj.visit_mut_with(self);
|
||||
|
||||
if e.computed {
|
||||
e.prop.visit_mut_with(self);
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_mut_module(&mut self, module: &mut Module) {
|
||||
module.visit_mut_children_with(self);
|
||||
|
||||
self.apply_ops(module)
|
||||
}
|
||||
|
||||
fn visit_mut_object_lit(&mut self, node: &mut ObjectLit) {
|
||||
let mut folder = Hygiene {
|
||||
config: self.config.clone(),
|
||||
current: Scope::new(ScopeKind::Block, Some(&self.current)),
|
||||
ident_type: IdentType::Ref,
|
||||
var_kind: None,
|
||||
};
|
||||
node.visit_mut_children_with(&mut folder);
|
||||
|
||||
folder.apply_ops(node)
|
||||
}
|
||||
|
||||
fn visit_mut_private_name(&mut self, _: &mut PrivateName) {}
|
||||
|
||||
fn visit_mut_setter_prop(&mut self, f: &mut SetterProp) {
|
||||
let old = self.ident_type;
|
||||
self.ident_type = IdentType::Ref;
|
||||
f.key.visit_mut_with(self);
|
||||
self.ident_type = old;
|
||||
|
||||
let old = self.ident_type;
|
||||
self.ident_type = IdentType::Binding;
|
||||
f.param.visit_mut_with(self);
|
||||
self.ident_type = old;
|
||||
|
||||
f.body.visit_mut_with(self);
|
||||
}
|
||||
|
||||
fn visit_mut_try_stmt(&mut self, node: &mut TryStmt) {
|
||||
node.block.visit_mut_children_with(self);
|
||||
|
||||
|
@ -4,6 +4,7 @@ use swc_common::{collections::AHashMap, hygiene::*, DUMMY_SP};
|
||||
use swc_ecma_parser::Syntax;
|
||||
use swc_ecma_utils::quote_ident;
|
||||
use swc_ecma_visit::{Fold, FoldWith};
|
||||
use testing::{assert_eq, DebugUsingDisplay};
|
||||
|
||||
struct Marker {
|
||||
map: AHashMap<JsWord, Mark>,
|
||||
@ -48,6 +49,13 @@ impl Fold for OnceMarker {
|
||||
|
||||
ident
|
||||
}
|
||||
|
||||
fn fold_prop_name(&mut self, prop: PropName) -> PropName {
|
||||
match prop {
|
||||
PropName::Computed(_) => prop.fold_children_with(self),
|
||||
_ => prop,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn test<F>(op: F, expected: &str)
|
||||
@ -94,10 +102,7 @@ where
|
||||
};
|
||||
|
||||
if actual != expected {
|
||||
panic!(
|
||||
"\n>>>>> Actual <<<<<\n{}\n>>>>> Expected <<<<<\n{}",
|
||||
actual, expected
|
||||
);
|
||||
assert_eq!(DebugUsingDisplay(&*actual), DebugUsingDisplay(&*expected));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@ -154,8 +159,8 @@ fn block_scoping_with_usage() {
|
||||
"
|
||||
var foo = 1;
|
||||
{
|
||||
let foo1 = 2;
|
||||
use(foo1);
|
||||
let foo = 2;
|
||||
use(foo);
|
||||
}
|
||||
use(foo);",
|
||||
);
|
||||
@ -181,7 +186,7 @@ fn block_scoping_no_usage() {
|
||||
"
|
||||
let foo;
|
||||
{
|
||||
let foo1;
|
||||
let foo;
|
||||
}
|
||||
",
|
||||
);
|
||||
@ -207,7 +212,7 @@ fn fn_binding_ident() {
|
||||
])
|
||||
},
|
||||
"var foo = function baz(){};
|
||||
var bar = function baz1(){};
|
||||
var bar = function baz(){};
|
||||
use(baz);",
|
||||
);
|
||||
}
|
||||
@ -236,8 +241,8 @@ fn fn_binding_ident_in_call() {
|
||||
])
|
||||
},
|
||||
"var foo = use(function baz(){});
|
||||
var bar1 = use(function baz1(){});
|
||||
var bar2 = use(function baz2(){});
|
||||
var bar1 = use(function baz(){});
|
||||
var bar2 = use(function baz(){});
|
||||
use(baz);",
|
||||
);
|
||||
}
|
||||
@ -280,8 +285,8 @@ fn const_then_fn_param() {
|
||||
])
|
||||
},
|
||||
"const a = 1;
|
||||
function foo(a1) {
|
||||
use(a1);
|
||||
function foo(a) {
|
||||
use(a);
|
||||
}",
|
||||
);
|
||||
}
|
||||
@ -370,8 +375,8 @@ fn shorthand() {
|
||||
"
|
||||
let a = 1;
|
||||
function foo() {
|
||||
let a1 = 2;
|
||||
use({ a: a1 })
|
||||
let a = 2;
|
||||
use({ a })
|
||||
}
|
||||
",
|
||||
);
|
||||
@ -563,7 +568,7 @@ fn block_in_fn() {
|
||||
function Foo() {
|
||||
var bar;
|
||||
{
|
||||
var bar1;
|
||||
var bar;
|
||||
}
|
||||
}
|
||||
",
|
||||
@ -727,8 +732,8 @@ fn for_x() {
|
||||
var { a } = _ref1, b = _objectWithoutProperties(_ref1, ['a']);
|
||||
}
|
||||
async function a() {
|
||||
for await (var _ref2 of []){
|
||||
var { a } = _ref2, b = _objectWithoutProperties(_ref2, ['a']);
|
||||
for await (var _ref of []){
|
||||
var { a } = _ref, b = _objectWithoutProperties(_ref, ['a']);
|
||||
}
|
||||
}
|
||||
",
|
||||
@ -1083,7 +1088,7 @@ fn issue_281_02() {
|
||||
"function foo(e) {
|
||||
e: {
|
||||
try {
|
||||
} catch (e1) {
|
||||
} catch (e) {
|
||||
o = null;
|
||||
break e
|
||||
}
|
||||
@ -1220,7 +1225,7 @@ fn issue_1279() {
|
||||
"
|
||||
let Foo = class Foo {
|
||||
method() {
|
||||
let Foo1 = class Foo {
|
||||
let Foo = class Foo {
|
||||
};
|
||||
}
|
||||
};
|
||||
@ -1262,3 +1267,237 @@ fn issue_1507() {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn opt_1() {
|
||||
test(
|
||||
|tester| {
|
||||
let mark1 = Mark::fresh(Mark::root());
|
||||
let mark2 = Mark::fresh(Mark::root());
|
||||
|
||||
let stmts = tester
|
||||
.parse_stmts(
|
||||
"actual1.js",
|
||||
"
|
||||
var foo = 1;
|
||||
{
|
||||
const foo = 2;
|
||||
{
|
||||
foo = foo + foo
|
||||
}
|
||||
}
|
||||
",
|
||||
)?
|
||||
.fold_with(&mut OnceMarker::new(&[(
|
||||
"foo",
|
||||
&[mark1, mark2, mark1, mark2, mark1],
|
||||
)]));
|
||||
Ok(stmts)
|
||||
},
|
||||
"
|
||||
var foo1 = 1;
|
||||
{
|
||||
const foo = 2;
|
||||
{
|
||||
foo1 = foo + foo1
|
||||
}
|
||||
}
|
||||
",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn opt_2() {
|
||||
test(
|
||||
|tester| {
|
||||
let mark1 = Mark::fresh(Mark::root());
|
||||
let mark2 = Mark::fresh(Mark::root());
|
||||
|
||||
let mark3 = Mark::fresh(Mark::root());
|
||||
let mark4 = Mark::fresh(Mark::root());
|
||||
|
||||
let stmts = tester
|
||||
.parse_stmts(
|
||||
"actual1.js",
|
||||
"
|
||||
var b = 1;
|
||||
var b1 = 2;
|
||||
{
|
||||
const b = 3;
|
||||
const b1 = 4;
|
||||
{
|
||||
b1 = b + b + b1 + b1
|
||||
}
|
||||
}
|
||||
",
|
||||
)?
|
||||
.fold_with(&mut OnceMarker::new(&[
|
||||
("b", &[mark1, mark2, mark2, mark1]),
|
||||
("b1", &[mark3, mark4, mark3, mark4, mark3]),
|
||||
]));
|
||||
Ok(stmts)
|
||||
},
|
||||
"
|
||||
var b = 1;
|
||||
var b11 = 2;
|
||||
{
|
||||
const b2 = 3;
|
||||
const b1 = 4;
|
||||
{
|
||||
b11 = b2 + b + b1 + b11
|
||||
}
|
||||
}
|
||||
",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn opt_3() {
|
||||
test(
|
||||
|tester| {
|
||||
let mark1 = Mark::fresh(Mark::root());
|
||||
let mark2 = Mark::fresh(Mark::root());
|
||||
|
||||
let stmts = tester
|
||||
.parse_stmts(
|
||||
"actual1.js",
|
||||
"
|
||||
var e = 1;
|
||||
try {
|
||||
throw 2;
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
",
|
||||
)?
|
||||
.fold_with(&mut OnceMarker::new(&[("e", &[mark1, mark2, mark1])]));
|
||||
Ok(stmts)
|
||||
},
|
||||
"
|
||||
var e = 1;
|
||||
try {
|
||||
throw 2;
|
||||
} catch (e1) {
|
||||
console.log(e);
|
||||
}
|
||||
",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn opt_4() {
|
||||
test(
|
||||
|tester| {
|
||||
let mark1 = Mark::fresh(Mark::root());
|
||||
let mark2 = Mark::fresh(Mark::root());
|
||||
|
||||
let stmts = tester
|
||||
.parse_stmts(
|
||||
"actual1.js",
|
||||
"
|
||||
const obj = {
|
||||
key: function a() {
|
||||
a()
|
||||
}
|
||||
}
|
||||
function a() {
|
||||
|
||||
}
|
||||
",
|
||||
)?
|
||||
.fold_with(&mut OnceMarker::new(&[("a", &[mark1, mark2, mark1])]));
|
||||
Ok(stmts)
|
||||
},
|
||||
"
|
||||
const obj = {
|
||||
key: function a1() {
|
||||
a()
|
||||
}
|
||||
}
|
||||
function a() {
|
||||
|
||||
}
|
||||
",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn opt_5() {
|
||||
test(
|
||||
|tester| {
|
||||
let mark1 = Mark::fresh(Mark::root());
|
||||
let mark2 = Mark::fresh(Mark::root());
|
||||
|
||||
let stmts = tester
|
||||
.parse_stmts(
|
||||
"actual1.js",
|
||||
"
|
||||
const obj = {
|
||||
a: function a() {
|
||||
a()
|
||||
}
|
||||
}
|
||||
function a() {
|
||||
|
||||
}
|
||||
",
|
||||
)?
|
||||
.fold_with(&mut OnceMarker::new(&[("a", &[mark1, mark2, mark1])]));
|
||||
Ok(stmts)
|
||||
},
|
||||
"
|
||||
const obj = {
|
||||
a: function a1() {
|
||||
a()
|
||||
}
|
||||
}
|
||||
function a() {
|
||||
|
||||
}
|
||||
",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn opt_6() {
|
||||
test(
|
||||
|tester| {
|
||||
let mark1 = Mark::fresh(Mark::root());
|
||||
let mark2 = Mark::fresh(Mark::root());
|
||||
|
||||
let stmts = tester
|
||||
.parse_stmts(
|
||||
"actual1.js",
|
||||
"
|
||||
var foo = 'bar';
|
||||
var Foo = function() {
|
||||
function Foo() {
|
||||
_bar.set(this, {
|
||||
writable: true,
|
||||
value: foo
|
||||
});
|
||||
var foo = 'foo';
|
||||
}
|
||||
|
||||
}
|
||||
",
|
||||
)?
|
||||
.fold_with(&mut OnceMarker::new(&[("foo", &[mark1, mark2, mark1])]));
|
||||
Ok(stmts)
|
||||
},
|
||||
"
|
||||
var foo = 'bar';
|
||||
var Foo = function() {
|
||||
function Foo() {
|
||||
_bar.set(this, {
|
||||
writable: true,
|
||||
value: foo
|
||||
});
|
||||
var foo1 = 'foo';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
",
|
||||
);
|
||||
}
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![deny(unused)]
|
||||
|
||||
#[doc(hidden)]
|
||||
pub mod ext;
|
||||
pub mod fixer;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -5,8 +5,7 @@ use swc_ecma_codegen::Emitter;
|
||||
use swc_ecma_parser::{lexer::Lexer, Parser, StringInput, Syntax};
|
||||
use swc_ecma_transforms_base::{
|
||||
fixer::fixer,
|
||||
hygiene::hygiene,
|
||||
resolver::{resolver, ts_resolver},
|
||||
resolver::{resolver_with_mark, ts_resolver},
|
||||
};
|
||||
use swc_ecma_visit::{as_folder, Fold, FoldWith, VisitMut, VisitMutWith};
|
||||
use testing::{fixture, run_test2, NormalizedOutput};
|
||||
@ -70,7 +69,13 @@ where
|
||||
#[fixture("tests/resolver/**/input.js")]
|
||||
fn test_resolver(input: PathBuf) {
|
||||
run(Syntax::default(), &input, || {
|
||||
chain!(resolver(), hygiene(), fixer(None))
|
||||
let top_level_mark = Mark::fresh(Mark::root());
|
||||
|
||||
chain!(
|
||||
resolver_with_mark(top_level_mark),
|
||||
as_folder(TsHygiene { top_level_mark }),
|
||||
fixer(None)
|
||||
)
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,14 @@
|
||||
foo.func1 = function () {
|
||||
if (cond1) {
|
||||
for (; ;) {
|
||||
if (cond2) {
|
||||
function func2() { }
|
||||
function func3() { }
|
||||
func4(function () {
|
||||
func2();
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
@ -0,0 +1,7 @@
|
||||
if (true) {
|
||||
function foo() { }
|
||||
function bar() {
|
||||
return foo;
|
||||
}
|
||||
for (var x in {}) { }
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
function WithoutCurlyBraces() {
|
||||
if (true)
|
||||
for (let k in kv) {
|
||||
function foo() { return this }
|
||||
function bar() { return foo.call(this) }
|
||||
console.log(this, k) // => undefined
|
||||
}
|
||||
}
|
||||
|
||||
function WithCurlyBraces() {
|
||||
if (true) {
|
||||
for (let k in kv) {
|
||||
function foo() { return this }
|
||||
function bar() { return foo.call(this) }
|
||||
console.log(this, k) // => 777
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
(function foo() {
|
||||
let foo = true;
|
||||
});
|
@ -0,0 +1,6 @@
|
||||
let arr = [];
|
||||
for (let i = 0; i < 10; i++) {
|
||||
for (let i = 0; i < 10; i++) {
|
||||
arr.push(() => i);
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
let arr = [];
|
||||
for(let i__2 = 0; i__2 < 10; i__2++){
|
||||
for(let i__3 = 0; i__3 < 10; i__3++){
|
||||
arr.push(()=>i__3
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
{
|
||||
var foo = 1;
|
||||
{
|
||||
let foo = 2;
|
||||
use(foo);
|
||||
}
|
||||
use(foo)
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
{
|
||||
var foo = 1;
|
||||
{
|
||||
let foo__2 = 2;
|
||||
use(foo__2);
|
||||
}
|
||||
use(foo);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
let foo;
|
||||
{
|
||||
let foo1;
|
||||
let foo__2;
|
||||
}
|
||||
|
@ -0,0 +1,12 @@
|
||||
|
||||
const g = 20;
|
||||
|
||||
function baz() {
|
||||
{
|
||||
class g {}
|
||||
console.log(g);
|
||||
}
|
||||
|
||||
return g;
|
||||
}
|
||||
|
@ -0,0 +1,9 @@
|
||||
const g = 20;
|
||||
function baz() {
|
||||
{
|
||||
class g__2 {
|
||||
}
|
||||
console.log(g__2);
|
||||
}
|
||||
return g;
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
var Foo = function (_Bar) {
|
||||
_inherits(Foo, _Bar);
|
||||
function Foo() {
|
||||
}
|
||||
return Foo;
|
||||
}(Bar);
|
@ -0,0 +1,6 @@
|
||||
var Foo = function(_Bar__2) {
|
||||
_inherits(Foo__2, _Bar__2);
|
||||
function Foo__2() {
|
||||
}
|
||||
return Foo__2;
|
||||
}(Bar);
|
@ -0,0 +1,6 @@
|
||||
var Foo = (function (_Bar) {
|
||||
_inherits(Foo, _Bar);
|
||||
function Foo() {
|
||||
}
|
||||
return Foo;
|
||||
})(Bar);
|
@ -0,0 +1,6 @@
|
||||
var Foo = function(_Bar__2) {
|
||||
_inherits(Foo__2, _Bar__2);
|
||||
function Foo__2() {
|
||||
}
|
||||
return Foo__2;
|
||||
}(Bar);
|
@ -0,0 +1,9 @@
|
||||
|
||||
let Test = 2;
|
||||
test(class Test {
|
||||
hi() {
|
||||
console.log(Test);
|
||||
}
|
||||
});
|
||||
Test = 4;
|
||||
|
@ -0,0 +1,7 @@
|
||||
let Test = 2;
|
||||
test(class Test__2 {
|
||||
hi() {
|
||||
console.log(Test__2);
|
||||
}
|
||||
});
|
||||
Test = 4;
|
@ -0,0 +1,20 @@
|
||||
var Outer = function (_Hello) {
|
||||
_inherits(Outer, _Hello);
|
||||
function Outer() {
|
||||
_classCallCheck(this, Outer);
|
||||
var _this = _possibleConstructorReturn(this, _getPrototypeOf(Outer).call(this));
|
||||
var Inner = function () {
|
||||
function Inner() {
|
||||
_classCallCheck(this, Inner);
|
||||
}
|
||||
_createClass(Inner, [{
|
||||
key: _get(_getPrototypeOf(Outer.prototype), 'toString', _assertThisInitialized(_this)).call(_this), value: function () {
|
||||
return 'hello';
|
||||
}
|
||||
}]);
|
||||
return Inner;
|
||||
}();
|
||||
return _possibleConstructorReturn(_this, new Inner());
|
||||
}
|
||||
return Outer;
|
||||
}(Hello);
|
@ -0,0 +1,23 @@
|
||||
var Outer = function(_Hello__2) {
|
||||
_inherits(Outer__2, _Hello__2);
|
||||
function Outer__2() {
|
||||
_classCallCheck(this, Outer__2);
|
||||
var _this__3 = _possibleConstructorReturn(this, _getPrototypeOf(Outer__2).call(this));
|
||||
var Inner__3 = function() {
|
||||
function Inner__4() {
|
||||
_classCallCheck(this, Inner__4);
|
||||
}
|
||||
_createClass(Inner__4, [
|
||||
{
|
||||
key: _get(_getPrototypeOf(Outer__2.prototype), 'toString', _assertThisInitialized(_this__3)).call(_this__3),
|
||||
value: function() {
|
||||
return 'hello';
|
||||
}
|
||||
}
|
||||
]);
|
||||
return Inner__4;
|
||||
}();
|
||||
return _possibleConstructorReturn(_this__3, new Inner__3());
|
||||
}
|
||||
return Outer__2;
|
||||
}(Hello);
|
@ -0,0 +1,8 @@
|
||||
var ConstructorScoping = function ConstructorScoping() {
|
||||
_classCallCheck(this, ConstructorScoping);
|
||||
var bar;
|
||||
{
|
||||
let bar;
|
||||
use(bar);
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
var ConstructorScoping = function ConstructorScoping__2() {
|
||||
_classCallCheck(this, ConstructorScoping__2);
|
||||
var bar__2;
|
||||
{
|
||||
let bar__3;
|
||||
use(bar__3);
|
||||
}
|
||||
};
|
@ -0,0 +1,14 @@
|
||||
var singleton;
|
||||
var Sub = function (_Foo) {
|
||||
_inherits(Sub, _Foo);
|
||||
function Sub() {
|
||||
var _this;
|
||||
_classCallCheck(this, Sub);
|
||||
if (singleton) {
|
||||
return _possibleConstructorReturn(_this, singleton);
|
||||
}
|
||||
singleton = _this = _possibleConstructorReturn(this, _getPrototypeOf(Sub).call(this));
|
||||
return _possibleConstructorReturn(_this);
|
||||
}
|
||||
return Sub;
|
||||
}(Foo);
|
@ -0,0 +1,14 @@
|
||||
var singleton;
|
||||
var Sub = function(_Foo__2) {
|
||||
_inherits(Sub__2, _Foo__2);
|
||||
function Sub__2() {
|
||||
var _this__3;
|
||||
_classCallCheck(this, Sub__2);
|
||||
if (singleton) {
|
||||
return _possibleConstructorReturn(_this__3, singleton);
|
||||
}
|
||||
singleton = _this__3 = _possibleConstructorReturn(this, _getPrototypeOf(Sub__2).call(this));
|
||||
return _possibleConstructorReturn(_this__3);
|
||||
}
|
||||
return Sub__2;
|
||||
}(Foo);
|
@ -0,0 +1,10 @@
|
||||
var Foo = function (_Bar) {
|
||||
_inherits(Foo, _Bar);
|
||||
function Foo() {
|
||||
var _this;
|
||||
_classCallCheck(this, Foo);
|
||||
Foo[_assertThisInitialized(_this)];
|
||||
return _possibleConstructorReturn(_this);
|
||||
}
|
||||
return Foo;
|
||||
}(Bar);
|
@ -0,0 +1,10 @@
|
||||
var Foo = function(_Bar__2) {
|
||||
_inherits(Foo__2, _Bar__2);
|
||||
function Foo__2() {
|
||||
var _this__3;
|
||||
_classCallCheck(this, Foo__2);
|
||||
Foo__2[_assertThisInitialized(_this__3)];
|
||||
return _possibleConstructorReturn(_this__3);
|
||||
}
|
||||
return Foo__2;
|
||||
}(Bar);
|
@ -0,0 +1 @@
|
||||
var Foo = function Foo() { }
|
@ -0,0 +1,2 @@
|
||||
var Foo = function Foo__2() {
|
||||
};
|
@ -0,0 +1,9 @@
|
||||
|
||||
const b = 1;
|
||||
const b1 = 2;
|
||||
{
|
||||
const b = 3;
|
||||
const b1 = 4;
|
||||
const b2 = 5;
|
||||
}
|
||||
|
@ -0,0 +1,7 @@
|
||||
const b = 1;
|
||||
const b1 = 2;
|
||||
{
|
||||
const b__2 = 3;
|
||||
const b1__2 = 4;
|
||||
const b2__2 = 5;
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user