diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index df7baccf..00000000 --- a/.editorconfig +++ /dev/null @@ -1,12 +0,0 @@ -# This file is for unifying the coding style for different editors and IDEs -# See editorconfig.org - -root = true - -[*] -indent_style = tab -indent_size = 2 -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true diff --git a/.eslintignore b/.eslintignore index 921f7b49..ebf56065 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1 +1,3 @@ -packages/metal-soy-bundle/src/**/*.js +*.soy.js +packages/metal-isomorphic/**/*.js +packages/metal-soy-bundle/**/*.js \ No newline at end of file diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 00000000..14f7560a --- /dev/null +++ b/.eslintrc @@ -0,0 +1,7 @@ +{ + "env": { + "browser": true, + "node": true + }, + "extends": "liferay" +} \ No newline at end of file diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index b892904d..00000000 --- a/.eslintrc.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "env": { - "browser": true, - "node": true - }, - "globals": {}, - "parserOptions": { - "ecmaVersion": 6, - "sourceType": "module", - "ecmaFeatures": { - "jsx": true - } - }, - "rules": { - "semi": 1, - "no-bitwise": 0, - "curly": 2, - "eqeqeq": 2, - "no-eval": 0, - "guard-for-in": 0, - "wrap-iife": [2, "any"], - "max-depth": 0, - "no-multi-str": 0, - "new-cap": 2, - "no-caller": 2, - "quotes": [ - 1, - "single", - { "allowTemplateLiterals": true } - ], - "strict": 0, - "no-undef": 2, - "no-unused-vars": 2 - } -} diff --git a/.travis.yml b/.travis.yml index c2b92efa..cca5a048 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ addons: secure: rV35O/fLO1NHiINBspiMzvWWtJPBdetUb3bB4mBB2Qrqf0WMRMGJ4Pgkaxl0p9JqAgPMQ/HSQTKLPNKaATc5g6GO46H7N1ykWBLrhsi7YSgopbNwUw95RebaZc42iyfgbnYG1hU8YEmes01UwXLsVup6qNt7X64I+M/KcfM6Cb8= before_install: - - nvm install 7 + - nvm install 8 - npm install -g gulp - npm install -g lerna@2.2.0 @@ -19,5 +19,7 @@ jdk: language: java script: + - npm run checkFormat + - npm run lint - gulp test:saucelabs - npm run test:isomorphic diff --git a/package-lock.json b/package-lock.json index 7ede5498..3a1ceb5d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2,6 +2,16 @@ "requires": true, "lockfileVersion": 1, "dependencies": { + "JSONStream": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.1.tgz", + "integrity": "sha1-cH92HgHa6eFvG8+TcDt4xwlmV5o=", + "dev": true, + "requires": { + "jsonparse": "1.3.1", + "through": "2.3.8" + } + }, "abab": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/abab/-/abab-1.0.4.tgz", @@ -69,32 +79,34 @@ "dev": true }, "ajv": { - "version": "4.11.8", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-4.11.8.tgz", - "integrity": "sha1-gv+wKynmYq5TvcIK8VlHcGc5xTY=", + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.3.0.tgz", + "integrity": "sha1-RBT/dKUIecII7l/cgm4ywwNUnto=", "dev": true, "requires": { "co": "4.6.0", - "json-stable-stringify": "1.0.1" - }, - "dependencies": { - "json-stable-stringify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", - "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", - "dev": true, - "requires": { - "jsonify": "0.0.0" - } - } + "fast-deep-equal": "1.0.0", + "fast-json-stable-stringify": "2.0.0", + "json-schema-traverse": "0.3.1" } }, "ajv-keywords": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-1.5.1.tgz", - "integrity": "sha1-MU3QpLM2j609/NxU7eYXG4htrzw=", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-2.1.1.tgz", + "integrity": "sha1-YXmX/F9gV2iUxDX5QNgZ4TW4B2I=", "dev": true }, + "align-text": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz", + "integrity": "sha1-DNkKVhCT810KmSVsIrcGlDP60Rc=", + "dev": true, + "requires": { + "kind-of": "3.2.2", + "longest": "1.0.1", + "repeat-string": "1.6.1" + } + }, "amdefine": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", @@ -102,9 +114,9 @@ "dev": true }, "ansi-escapes": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-1.4.0.tgz", - "integrity": "sha1-06ioOzGapneTZisT52HHkRQiMG4=", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.0.0.tgz", + "integrity": "sha512-O/klc27mWNUigtv0F8NJWbLF00OcegQalkqKURWdosW08YZKi4m6CnSUSvIZG1otNJbTWhN01Hhz389DW7mvDQ==", "dev": true }, "ansi-regex": { @@ -129,6 +141,12 @@ "normalize-path": "2.1.1" } }, + "app-root-path": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/app-root-path/-/app-root-path-2.0.1.tgz", + "integrity": "sha1-zWLc+OT9WkF+/GZNLlsQZTxlG0Y=", + "dev": true + }, "aproba": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz", @@ -211,6 +229,16 @@ "integrity": "sha1-nlKHYrSpBmrRY6aWKjZEGOlibs4=", "dev": true }, + "array-includes": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.0.3.tgz", + "integrity": "sha1-GEtI9i2S10UrsxsyMWXH+L0CJm0=", + "dev": true, + "requires": { + "define-properties": "1.1.2", + "es-abstract": "1.9.0" + } + }, "array-map": { "version": "0.0.0", "resolved": "https://registry.npmjs.org/array-map/-/array-map-0.0.0.tgz", @@ -250,16 +278,6 @@ "integrity": "sha1-odl8yvy8JiXMcPrc6zalDFiwGlM=", "dev": true }, - "array.prototype.find": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/array.prototype.find/-/array.prototype.find-2.0.4.tgz", - "integrity": "sha1-VWpcU2LAhkgyPdrrnenRS8GGTJA=", - "dev": true, - "requires": { - "define-properties": "1.1.2", - "es-abstract": "1.9.0" - } - }, "arraybuffer.slice": { "version": "0.0.6", "resolved": "https://registry.npmjs.org/arraybuffer.slice/-/arraybuffer.slice-0.0.6.tgz", @@ -272,6 +290,12 @@ "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=", "dev": true }, + "asap": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", + "integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=", + "dev": true + }, "asn1": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz", @@ -279,9 +303,9 @@ "dev": true }, "asn1.js": { - "version": "4.9.1", - "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.9.1.tgz", - "integrity": "sha1-SLokC0WpKA6UdImQull9IWYX/UA=", + "version": "4.9.2", + "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.9.2.tgz", + "integrity": "sha512-b/OsSjvWEo8Pi8H0zsDd2P6Uqo2TK2pH8gNLSJtNLM2Db0v2QaAZ0pBQJXVjAn4gBuugeVDr7s63ZogpUIwWDg==", "dev": true, "requires": { "bn.js": "4.11.8", @@ -344,7 +368,7 @@ "dev": true, "requires": { "browserslist": "1.7.7", - "caniuse-db": "1.0.30000746", + "caniuse-db": "1.0.30000760", "normalize-range": "0.1.2", "num2fraction": "1.2.2", "postcss": "5.2.18", @@ -357,8 +381,8 @@ "integrity": "sha1-C9dnBCWL6CmyOYu1Dkti0aFmsLk=", "dev": true, "requires": { - "caniuse-db": "1.0.30000746", - "electron-to-chromium": "1.3.25" + "caniuse-db": "1.0.30000760", + "electron-to-chromium": "1.3.27" } } } @@ -408,7 +432,7 @@ "lodash": "4.17.4", "minimatch": "3.0.4", "path-is-absolute": "1.0.1", - "private": "0.1.7", + "private": "0.1.8", "slash": "1.0.0", "source-map": "0.5.7" } @@ -601,7 +625,7 @@ "dev": true, "requires": { "find-up": "1.1.2", - "istanbul-lib-instrument": "1.8.0", + "istanbul-lib-instrument": "1.9.1", "test-exclude": "1.1.0" } }, @@ -905,9 +929,9 @@ } }, "babel-preset-env": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/babel-preset-env/-/babel-preset-env-1.6.0.tgz", - "integrity": "sha512-OVgtQRuOZKckrILgMA5rvctvFZPv72Gua9Rt006AiPoB0DJKGN07UmaQA+qRrYgK71MVct8fFhT0EyNWYorVew==", + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/babel-preset-env/-/babel-preset-env-1.6.1.tgz", + "integrity": "sha512-W6VIyA6Ch9ePMI7VptNn2wBM6dbG0eSz25HEiL40nQXCsXGTGZSTZu1Iap+cj3Q0S5a7T9+529l/5Bkvd+afNA==", "dev": true, "requires": { "babel-plugin-check-es2015-constants": "6.22.0", @@ -937,7 +961,7 @@ "babel-plugin-transform-es2015-unicode-regex": "6.24.1", "babel-plugin-transform-exponentiation-operator": "6.24.1", "babel-plugin-transform-regenerator": "6.26.0", - "browserslist": "2.5.1", + "browserslist": "2.8.0", "invariant": "2.2.2", "semver": "5.4.1" } @@ -1064,6 +1088,16 @@ "integrity": "sha1-R2iMuZu2gE8OBtPnY7HDLlfY5rY=", "dev": true }, + "bcrypt-pbkdf": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz", + "integrity": "sha1-Y7xdy2EzG5K8Bf1SiVPDNGKgb40=", + "dev": true, + "optional": true, + "requires": { + "tweetnacl": "0.14.5" + } + }, "beeper": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/beeper/-/beeper-1.1.1.tgz", @@ -1125,16 +1159,14 @@ "qs": "6.5.1", "raw-body": "2.3.2", "type-is": "1.6.15" - }, - "dependencies": { - "iconv-lite": { - "version": "0.4.19", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz", - "integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ==", - "dev": true - } } }, + "boolify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/boolify/-/boolify-1.0.1.tgz", + "integrity": "sha1-tcCeF8rNET0Rt7s+04TMASmU2Gs=", + "dev": true + }, "boom": { "version": "4.3.1", "resolved": "https://registry.npmjs.org/boom/-/boom-4.3.1.tgz", @@ -1177,9 +1209,9 @@ "integrity": "sha1-+GzWzvT1MAyOY+B6TVEvZfv/RTE=", "dev": true, "requires": { + "JSONStream": "1.3.1", "combine-source-map": "0.7.2", "defined": "1.0.0", - "JSONStream": "1.3.1", "through2": "2.0.3", "umd": "3.0.1" } @@ -1207,6 +1239,7 @@ "integrity": "sha1-tanJAgJD8McORnW+yCI7xifkFc4=", "dev": true, "requires": { + "JSONStream": "1.3.1", "assert": "1.4.1", "browser-pack": "6.0.2", "browser-resolve": "1.11.2", @@ -1216,7 +1249,7 @@ "concat-stream": "1.5.2", "console-browserify": "1.1.0", "constants-browserify": "1.0.0", - "crypto-browserify": "3.11.1", + "crypto-browserify": "3.12.0", "defined": "1.0.0", "deps-sort": "2.0.0", "domain-browser": "1.1.7", @@ -1228,7 +1261,6 @@ "https-browserify": "0.0.1", "inherits": "2.0.3", "insert-module-globals": "7.0.1", - "JSONStream": "1.3.1", "labeled-stream-splicer": "2.0.0", "module-deps": "4.1.1", "os-browserify": "0.1.2", @@ -1239,7 +1271,7 @@ "querystring-es3": "0.2.1", "read-only-stream": "2.0.0", "readable-stream": "2.3.3", - "resolve": "1.4.0", + "resolve": "1.5.0", "shasum": "1.0.2", "shell-quote": "1.6.1", "stream-browserify": "2.0.1", @@ -1257,9 +1289,9 @@ } }, "browserify-aes": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.0.8.tgz", - "integrity": "sha512-WYCMOT/PtGTlpOKFht0YJFYcPy6pLCR98CtWfzK13zoynLlBMvAdEMSRGmgnJCw2M2j/5qxBkinZQFobieM8dQ==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.1.1.tgz", + "integrity": "sha512-UGnTYAnB2a3YuYKIRy1/4FB2HdM866E0qC46JXvVTYKlBlZlnvfpSfY6OKfXZAkv70eJ2a1SqzpAo5CRhZGDFg==", "dev": true, "requires": { "buffer-xor": "1.0.3", @@ -1276,7 +1308,7 @@ "integrity": "sha1-mYgkSHS/XtTijalWZtzWasj8Njo=", "dev": true, "requires": { - "browserify-aes": "1.0.8", + "browserify-aes": "1.1.1", "browserify-des": "1.0.0", "evp_bytestokey": "1.0.3" } @@ -1327,13 +1359,13 @@ } }, "browserslist": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-2.5.1.tgz", - "integrity": "sha512-jAvM2ku7YDJ+leAq3bFH1DE0Ylw+F+EQDq4GkqZfgPEqpWYw9ofQH85uKSB9r3Tv7XDbfqVtE+sdvKJW7IlPJA==", + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-2.8.0.tgz", + "integrity": "sha512-iiWHM1Et6Q4TQpB7Ar6pxuM3TNMXasVJY4Y/oh3q38EwR3Z+IdZ9MyVf7PI4MJFB4xpwMcZgs9bEUnPG2E3TCA==", "dev": true, "requires": { - "caniuse-lite": "1.0.30000746", - "electron-to-chromium": "1.3.25" + "caniuse-lite": "1.0.30000760", + "electron-to-chromium": "1.3.27" } }, "buffer": { @@ -1421,15 +1453,21 @@ } }, "caniuse-db": { - "version": "1.0.30000746", - "resolved": "https://registry.npmjs.org/caniuse-db/-/caniuse-db-1.0.30000746.tgz", - "integrity": "sha1-UBCYxm9fu/Y0wC8lUIsF6ICZEPQ=", + "version": "1.0.30000760", + "resolved": "https://registry.npmjs.org/caniuse-db/-/caniuse-db-1.0.30000760.tgz", + "integrity": "sha1-PqKUc+t4psywny63Osnh3r/sUo0=", "dev": true }, "caniuse-lite": { - "version": "1.0.30000746", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000746.tgz", - "integrity": "sha1-xk+Vo5Jc/TAgejCO12wa6W6gnqA=", + "version": "1.0.30000760", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000760.tgz", + "integrity": "sha1-7HIDlXQvHH7IlH/W3SYE53qPmP8=", + "dev": true + }, + "capture-stack-trace": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/capture-stack-trace/-/capture-stack-trace-1.0.0.tgz", + "integrity": "sha1-Sm+gc5nCa7pH8LJJa00PtAjFVQ0=", "dev": true }, "caseless": { @@ -1438,6 +1476,17 @@ "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=", "dev": true }, + "center-align": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/center-align/-/center-align-0.1.3.tgz", + "integrity": "sha1-qg0yYptu6XIgBBHL1EYckHvCt60=", + "dev": true, + "optional": true, + "requires": { + "align-text": "0.1.4", + "lazy-cache": "1.0.4" + } + }, "chai": { "version": "3.5.0", "resolved": "https://registry.npmjs.org/chai/-/chai-3.5.0.tgz", @@ -1470,6 +1519,7 @@ "requires": { "anymatch": "1.3.2", "async-each": "1.0.1", + "fsevents": "1.1.2", "glob-parent": "2.0.0", "inherits": "2.0.3", "is-binary-path": "1.0.1", @@ -1501,12 +1551,56 @@ "dev": true }, "cli-cursor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-1.0.2.tgz", - "integrity": "sha1-ZNo/fValRBLll5S9Ytw1KV6PKYc=", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", + "integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=", + "dev": true, + "requires": { + "restore-cursor": "2.0.0" + } + }, + "cli-spinners": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-0.1.2.tgz", + "integrity": "sha1-u3ZNiOGF+54eaiofGXcjGPYF4xw=", + "dev": true + }, + "cli-truncate": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/cli-truncate/-/cli-truncate-0.2.1.tgz", + "integrity": "sha1-nxXPuwcFAFNpIWxiasfQWrkN1XQ=", "dev": true, "requires": { - "restore-cursor": "1.0.1" + "slice-ansi": "0.0.4", + "string-width": "1.0.2" + }, + "dependencies": { + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "dev": true, + "requires": { + "number-is-nan": "1.0.1" + } + }, + "slice-ansi": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-0.0.4.tgz", + "integrity": "sha1-7b+JA/ZvfOL46v1s7tZeJkyDGzU=", + "dev": true + }, + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "dev": true, + "requires": { + "code-point-at": "1.1.0", + "is-fullwidth-code-point": "1.0.0", + "strip-ansi": "3.0.1" + } + } } }, "cli-width": { @@ -1524,12 +1618,34 @@ "string-width": "1.0.2", "strip-ansi": "3.0.1", "wrap-ansi": "2.1.0" + }, + "dependencies": { + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "dev": true, + "requires": { + "number-is-nan": "1.0.1" + } + }, + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "dev": true, + "requires": { + "code-point-at": "1.1.0", + "is-fullwidth-code-point": "1.0.0", + "strip-ansi": "3.0.1" + } + } } }, "clone": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.2.tgz", - "integrity": "sha1-Jgt6meux7f4kdTgXX3gyQ8sZ0Uk=", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.3.tgz", + "integrity": "sha1-KY1+IjFmD0DAA8LtMUDezz9TCF8=", "dev": true }, "clone-stats": { @@ -1567,9 +1683,9 @@ "dev": true }, "color-convert": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.0.tgz", - "integrity": "sha1-Gsz5fdc5uYO/mU1W/sj5WFNkG3o=", + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", + "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", "dev": true, "requires": { "color-name": "1.1.3" @@ -1647,6 +1763,15 @@ "integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ==", "dev": true }, + "common-tags": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/common-tags/-/common-tags-1.4.0.tgz", + "integrity": "sha1-EYe+Tz1M8MBCfUP3Tu8fc1AWFMA=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0" + } + }, "compare-func": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/compare-func/-/compare-func-1.3.2.tgz", @@ -1748,9 +1873,9 @@ "dev": true }, "content-type-parser": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/content-type-parser/-/content-type-parser-1.0.1.tgz", - "integrity": "sha1-w+VpiMU8ZRJ/tG1AMqOpACRv3JQ=", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/content-type-parser/-/content-type-parser-1.0.2.tgz", + "integrity": "sha512-lM4l4CnMEwOLHAHr/P6MEZwZFPJFtAAKgL6pogbXmVZggIqXhdB6RbBtPOTsw2FcXwYhehRGERJmRrjOiIB8pQ==", "dev": true }, "conventional-changelog": { @@ -1778,7 +1903,7 @@ "dev": true, "requires": { "compare-func": "1.3.2", - "q": "1.5.0" + "q": "1.5.1" } }, "conventional-changelog-atom": { @@ -1787,7 +1912,7 @@ "integrity": "sha512-6Nlu/+MiD4gi7k3Z+N1vMJWpaPSdvFPWzPGnH4OXewHAxiAl0L/TT9CGgA01fosPxmYr4hMNtD7kyN0tkg8vIA==", "dev": true, "requires": { - "q": "1.5.0" + "q": "1.5.1" } }, "conventional-changelog-cli": { @@ -1809,7 +1934,7 @@ "integrity": "sha512-jUbY98JoKdAOR5k3pOBiKZ+Iz9t2F84hL7x4WjSRW6x7FdeCEUOjyfml+YClE2h/h62Tf3mwur5jSO8upxxc1g==", "dev": true, "requires": { - "q": "1.5.0" + "q": "1.5.1" } }, "conventional-changelog-core": { @@ -1827,7 +1952,7 @@ "git-semver-tags": "1.2.2", "lodash": "4.17.4", "normalize-package-data": "2.4.0", - "q": "1.5.0", + "q": "1.5.1", "read-pkg": "1.1.0", "read-pkg-up": "1.0.1", "through2": "2.0.3" @@ -1851,7 +1976,7 @@ "integrity": "sha512-smsh0o/S95n22lrQZrSHYjJrxIGoFl+OFHK+q2KGHA2zRFrW7QilYM7VUjgmB+emzwqFguPjrq+D2U8iPhMNJg==", "dev": true, "requires": { - "q": "1.5.0" + "q": "1.5.1" } }, "conventional-changelog-eslint": { @@ -1860,7 +1985,7 @@ "integrity": "sha512-WGKnC0bGPD6BHGiRBfYqNGfy6DZDn2jGs1yxPRT8I2796wYdGqsbDF4477o4fdsxUJvckoW2OFPqkmRMQaCHSA==", "dev": true, "requires": { - "q": "1.5.0" + "q": "1.5.1" } }, "conventional-changelog-express": { @@ -1869,7 +1994,7 @@ "integrity": "sha512-ujSEmbWfozC1iIjH5Pl7AKtREowvAl10whs1q6c7nZLnoNZK5CmdB2PQ/V42O6rCgUzaLX+ACRW2+g0A/Htqvw==", "dev": true, "requires": { - "q": "1.5.0" + "q": "1.5.1" } }, "conventional-changelog-jquery": { @@ -1878,7 +2003,7 @@ "integrity": "sha1-Agg5cWLjhGmG5xJztsecW1+A9RA=", "dev": true, "requires": { - "q": "1.5.0" + "q": "1.5.1" } }, "conventional-changelog-jscs": { @@ -1887,7 +2012,7 @@ "integrity": "sha1-BHnrRDzH1yxYvwvPDvHURKkvDlw=", "dev": true, "requires": { - "q": "1.5.0" + "q": "1.5.1" } }, "conventional-changelog-jshint": { @@ -1897,7 +2022,7 @@ "dev": true, "requires": { "compare-func": "1.3.2", - "q": "1.5.0" + "q": "1.5.1" } }, "conventional-changelog-writer": { @@ -1909,7 +2034,7 @@ "compare-func": "1.3.2", "conventional-commits-filter": "1.0.0", "dateformat": "1.0.12", - "handlebars": "4.0.10", + "handlebars": "4.0.11", "json-stringify-safe": "5.0.1", "lodash": "4.17.4", "meow": "3.7.0", @@ -1946,8 +2071,8 @@ "integrity": "sha512-8od6g684Fhi5Vpp4ABRv/RBsW1AY6wSHbJHEK6FGTv+8jvAAnlABniZu/FVmX9TcirkHepaEsa1QGkRvbg0CKw==", "dev": true, "requires": { - "is-text-path": "1.0.1", "JSONStream": "1.3.1", + "is-text-path": "1.0.1", "lodash": "4.17.4", "meow": "3.7.0", "split2": "2.2.0", @@ -1994,6 +2119,30 @@ "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", "dev": true }, + "cosmiconfig": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-1.1.0.tgz", + "integrity": "sha1-DeoPmATv37kp+7GxiOJVU+oFPTc=", + "dev": true, + "requires": { + "graceful-fs": "4.1.11", + "js-yaml": "3.10.0", + "minimist": "1.2.0", + "object-assign": "4.1.1", + "os-homedir": "1.0.2", + "parse-json": "2.2.0", + "pinkie-promise": "2.0.1", + "require-from-string": "1.2.1" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "dev": true + } + } + }, "create-ecdh": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.0.tgz", @@ -2004,6 +2153,15 @@ "elliptic": "6.4.0" } }, + "create-error-class": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/create-error-class/-/create-error-class-3.0.2.tgz", + "integrity": "sha1-Br56vvlHo/FKMP1hBnHUAbyot7Y=", + "dev": true, + "requires": { + "capture-stack-trace": "1.0.0" + } + }, "create-hash": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.1.3.tgz", @@ -2039,18 +2197,6 @@ "lru-cache": "4.1.1", "shebang-command": "1.2.0", "which": "1.3.0" - }, - "dependencies": { - "lru-cache": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.1.tgz", - "integrity": "sha512-q4spe4KTfsAS1SUHLO0wz8Qiyf1+vMIAgpRYioFYDMNqKfHQbg+AVDH3i4fvpl71/P1L0dBl+fQi+P37UYf0ew==", - "dev": true, - "requires": { - "pseudomap": "1.0.2", - "yallist": "2.1.2" - } - } } }, "cryptiles": { @@ -2074,9 +2220,9 @@ } }, "crypto-browserify": { - "version": "3.11.1", - "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.11.1.tgz", - "integrity": "sha512-Na7ZlwCOqoaW5RwUK1WpXws2kv8mNhWdTlzob0UXulk6G9BDbyiJaGTYBIX61Ozn9l1EPPJpICZb4DaOpT9NlQ==", + "version": "3.12.0", + "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.0.tgz", + "integrity": "sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg==", "dev": true, "requires": { "browserify-cipher": "1.0.0", @@ -2088,7 +2234,8 @@ "inherits": "2.0.3", "pbkdf2": "3.0.14", "public-encrypt": "4.0.0", - "randombytes": "2.0.5" + "randombytes": "2.0.5", + "randomfill": "1.0.3" } }, "cssom": { @@ -2127,7 +2274,7 @@ "integrity": "sha1-dUu1v+VUUdpppYuU1F9MWwRi1Y8=", "dev": true, "requires": { - "es5-ext": "0.10.31" + "es5-ext": "0.10.35" } }, "dargs": { @@ -2148,6 +2295,12 @@ "assert-plus": "1.0.0" } }, + "date-fns": { + "version": "1.29.0", + "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-1.29.0.tgz", + "integrity": "sha512-lbTXWZ6M20cWH8N9S6afb0SBm6tMk+uUg6z3MqHPKE9atmsY3kJkTm8vKe93izJ2B2+q5MV990sM2CHgtAZaOw==", + "dev": true + }, "date-now": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz", @@ -2198,6 +2351,12 @@ } } }, + "deep-extend": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.4.2.tgz", + "integrity": "sha1-SLaZwn4zS/ifEIkr5DL25MfTSn8=", + "dev": true + }, "deep-is": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", @@ -2210,7 +2369,7 @@ "integrity": "sha1-xlYFHpgX2f8I7YgUd/P+QBnz730=", "dev": true, "requires": { - "clone": "1.0.2" + "clone": "1.0.3" } }, "define-properties": { @@ -2341,10 +2500,16 @@ "randombytes": "2.0.5" } }, + "dlv": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/dlv/-/dlv-1.1.0.tgz", + "integrity": "sha1-/uGnxD9jvnXz9nnoUmLaXxAnZKc=", + "dev": true + }, "doctrine": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-1.5.0.tgz", - "integrity": "sha1-N53Ocw9hZvds76TmcHoVmwLFpvo=", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.0.0.tgz", + "integrity": "sha1-xz2NKQnSIpHhoAejlYBNqLZl/mM=", "dev": true, "requires": { "esutils": "2.0.2", @@ -2393,6 +2558,12 @@ "readable-stream": "2.3.3" } }, + "duplexer3": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/duplexer3/-/duplexer3-0.1.4.tgz", + "integrity": "sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI=", + "dev": true + }, "duplexify": { "version": "3.5.1", "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-3.5.1.tgz", @@ -2416,6 +2587,16 @@ } } }, + "ecc-jsbn": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz", + "integrity": "sha1-D8c6ntXw1Tw4GTOYUj735UN3dQU=", + "dev": true, + "optional": true, + "requires": { + "jsbn": "0.1.1" + } + }, "ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", @@ -2423,9 +2604,15 @@ "dev": true }, "electron-to-chromium": { - "version": "1.3.25", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.25.tgz", - "integrity": "sha1-RTshAJg20Jl9hgNWAf9srkeRxGA=", + "version": "1.3.27", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.27.tgz", + "integrity": "sha1-eOy4o5kGYYe7N07t412ccFZagD0=", + "dev": true + }, + "elegant-spinner": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/elegant-spinner/-/elegant-spinner-1.0.1.tgz", + "integrity": "sha1-2wQ1IcldfjA/2PNFvtwzSc+wcp4=", "dev": true }, "elliptic": { @@ -2449,6 +2636,15 @@ "integrity": "sha1-eePVhlU0aQn+bw9Fpd5oEDspTSA=", "dev": true }, + "encoding": { + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz", + "integrity": "sha1-U4tm8+5izRq1HsMjgp0flIDHS+s=", + "dev": true, + "requires": { + "iconv-lite": "0.4.19" + } + }, "end-of-stream": { "version": "0.1.5", "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-0.1.5.tgz", @@ -2597,23 +2793,23 @@ } }, "es5-ext": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.31.tgz", - "integrity": "sha1-e7k4yVp/G59ygJLcCcQe3MOY7v4=", + "version": "0.10.35", + "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.35.tgz", + "integrity": "sha1-GO6FjOajxFx9eekcFfzKnsVoSU8=", "dev": true, "requires": { - "es6-iterator": "2.0.1", + "es6-iterator": "2.0.3", "es6-symbol": "3.1.1" } }, "es6-iterator": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.1.tgz", - "integrity": "sha1-jjGcnwRTv1ddN0lAplWSDlnKVRI=", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz", + "integrity": "sha1-p96IkUGgWpSwhUQDstCg+/qY87c=", "dev": true, "requires": { "d": "1.0.0", - "es5-ext": "0.10.31", + "es5-ext": "0.10.35", "es6-symbol": "3.1.1" } }, @@ -2624,8 +2820,8 @@ "dev": true, "requires": { "d": "1.0.0", - "es5-ext": "0.10.31", - "es6-iterator": "2.0.1", + "es5-ext": "0.10.35", + "es6-iterator": "2.0.3", "es6-set": "0.1.5", "es6-symbol": "3.1.1", "event-emitter": "0.3.5" @@ -2643,59 +2839,306 @@ "lodash": "4.17.4", "posix-getopt": "1.2.0", "typhonjs-escomplex": "0.0.12" - } - }, - "es6-set": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/es6-set/-/es6-set-0.1.5.tgz", - "integrity": "sha1-0rPsXU2ADO2BjbU40ol02wpzzLE=", - "dev": true, - "requires": { - "d": "1.0.0", - "es5-ext": "0.10.31", - "es6-iterator": "2.0.1", - "es6-symbol": "3.1.1", - "event-emitter": "0.3.5" - } - }, - "es6-symbol": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.1.tgz", - "integrity": "sha1-vwDvT9q2uhtG7Le2KbTH7VcVzHc=", - "dev": true, - "requires": { - "d": "1.0.0", - "es5-ext": "0.10.31" - } - }, - "es6-weak-map": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/es6-weak-map/-/es6-weak-map-2.0.2.tgz", - "integrity": "sha1-XjqzIlH/0VOKH45f+hNXdy+S2W8=", - "dev": true, - "requires": { - "d": "1.0.0", - "es5-ext": "0.10.31", - "es6-iterator": "2.0.1", - "es6-symbol": "3.1.1" - } - }, - "escape-html": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", - "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=", - "dev": true - }, - "escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", - "dev": true - }, - "escodegen": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.9.0.tgz", - "integrity": "sha512-v0MYvNQ32bzwoG2OSFzWAkuahDQHK92JBN0pTAALJ4RIxEZe766QJPDR8Hqy7XNUy5K3fnVL76OqYAdc4TZEIw==", + }, + "dependencies": { + "ajv": { + "version": "4.11.8", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-4.11.8.tgz", + "integrity": "sha1-gv+wKynmYq5TvcIK8VlHcGc5xTY=", + "dev": true, + "requires": { + "co": "4.6.0", + "json-stable-stringify": "1.0.1" + } + }, + "ajv-keywords": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-1.5.1.tgz", + "integrity": "sha1-MU3QpLM2j609/NxU7eYXG4htrzw=", + "dev": true + }, + "ansi-escapes": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-1.4.0.tgz", + "integrity": "sha1-06ioOzGapneTZisT52HHkRQiMG4=", + "dev": true + }, + "cli-cursor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-1.0.2.tgz", + "integrity": "sha1-ZNo/fValRBLll5S9Ytw1KV6PKYc=", + "dev": true, + "requires": { + "restore-cursor": "1.0.1" + } + }, + "eslint": { + "version": "3.19.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-3.19.0.tgz", + "integrity": "sha1-yPxiAcf0DdCJQbh8CFdnOGpnmsw=", + "dev": true, + "requires": { + "babel-code-frame": "6.26.0", + "chalk": "1.1.3", + "concat-stream": "1.5.2", + "debug": "2.6.9", + "doctrine": "2.0.0", + "escope": "3.6.0", + "espree": "3.5.1", + "esquery": "1.0.0", + "estraverse": "4.2.0", + "esutils": "2.0.2", + "file-entry-cache": "2.0.0", + "glob": "7.1.2", + "globals": "9.18.0", + "ignore": "3.3.7", + "imurmurhash": "0.1.4", + "inquirer": "0.12.0", + "is-my-json-valid": "2.16.1", + "is-resolvable": "1.0.0", + "js-yaml": "3.10.0", + "json-stable-stringify": "1.0.1", + "levn": "0.3.0", + "lodash": "4.17.4", + "mkdirp": "0.5.1", + "natural-compare": "1.4.0", + "optionator": "0.8.2", + "path-is-inside": "1.0.2", + "pluralize": "1.2.1", + "progress": "1.1.8", + "require-uncached": "1.0.3", + "shelljs": "0.7.8", + "strip-bom": "3.0.0", + "strip-json-comments": "2.0.1", + "table": "3.8.3", + "text-table": "0.2.0", + "user-home": "2.0.0" + } + }, + "figures": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/figures/-/figures-1.7.0.tgz", + "integrity": "sha1-y+Hjr/zxzUS4DK3+0o3Hk6lwHS4=", + "dev": true, + "requires": { + "escape-string-regexp": "1.0.5", + "object-assign": "4.1.1" + } + }, + "inquirer": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-0.12.0.tgz", + "integrity": "sha1-HvK/1jUE3wvHV4X/+MLEHfEvB34=", + "dev": true, + "requires": { + "ansi-escapes": "1.4.0", + "ansi-regex": "2.1.1", + "chalk": "1.1.3", + "cli-cursor": "1.0.2", + "cli-width": "2.2.0", + "figures": "1.7.0", + "lodash": "4.17.4", + "readline2": "1.0.1", + "run-async": "0.1.0", + "rx-lite": "3.1.2", + "string-width": "1.0.2", + "strip-ansi": "3.0.1", + "through": "2.3.8" + } + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "dev": true, + "requires": { + "number-is-nan": "1.0.1" + } + }, + "json-stable-stringify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", + "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", + "dev": true, + "requires": { + "jsonify": "0.0.0" + } + }, + "onetime": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz", + "integrity": "sha1-ofeDj4MUxRbwXs78vEzP4EtO14k=", + "dev": true + }, + "pluralize": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-1.2.1.tgz", + "integrity": "sha1-0aIUg/0iu0HlihL6NCGCMUCJfEU=", + "dev": true + }, + "progress": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/progress/-/progress-1.1.8.tgz", + "integrity": "sha1-4mDHj2Fhzdmw5WzD4Khd4Xx6V74=", + "dev": true + }, + "restore-cursor": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-1.0.1.tgz", + "integrity": "sha1-NGYfRohjJ/7SmRR5FSJS35LapUE=", + "dev": true, + "requires": { + "exit-hook": "1.1.1", + "onetime": "1.1.0" + } + }, + "run-async": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/run-async/-/run-async-0.1.0.tgz", + "integrity": "sha1-yK1KXhEGYeQCp9IbUw4AnyX444k=", + "dev": true, + "requires": { + "once": "1.4.0" + } + }, + "rx-lite": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-3.1.2.tgz", + "integrity": "sha1-Gc5QLKVyZl87ZHsQk5+X/RYV8QI=", + "dev": true + }, + "slice-ansi": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-0.0.4.tgz", + "integrity": "sha1-7b+JA/ZvfOL46v1s7tZeJkyDGzU=", + "dev": true + }, + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "dev": true, + "requires": { + "code-point-at": "1.1.0", + "is-fullwidth-code-point": "1.0.0", + "strip-ansi": "3.0.1" + } + }, + "strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", + "dev": true + }, + "table": { + "version": "3.8.3", + "resolved": "https://registry.npmjs.org/table/-/table-3.8.3.tgz", + "integrity": "sha1-K7xULw/amGGnVdOUf+/Ys/UThV8=", + "dev": true, + "requires": { + "ajv": "4.11.8", + "ajv-keywords": "1.5.1", + "chalk": "1.1.3", + "lodash": "4.17.4", + "slice-ansi": "0.0.4", + "string-width": "2.1.1" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "2.0.0", + "strip-ansi": "4.0.0" + } + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "3.0.0" + } + } + } + }, + "user-home": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/user-home/-/user-home-2.0.0.tgz", + "integrity": "sha1-nHC/2Babwdy/SGBODwS4tJzenp8=", + "dev": true, + "requires": { + "os-homedir": "1.0.2" + } + } + } + }, + "es6-set": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/es6-set/-/es6-set-0.1.5.tgz", + "integrity": "sha1-0rPsXU2ADO2BjbU40ol02wpzzLE=", + "dev": true, + "requires": { + "d": "1.0.0", + "es5-ext": "0.10.35", + "es6-iterator": "2.0.3", + "es6-symbol": "3.1.1", + "event-emitter": "0.3.5" + } + }, + "es6-symbol": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.1.tgz", + "integrity": "sha1-vwDvT9q2uhtG7Le2KbTH7VcVzHc=", + "dev": true, + "requires": { + "d": "1.0.0", + "es5-ext": "0.10.35" + } + }, + "es6-weak-map": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/es6-weak-map/-/es6-weak-map-2.0.2.tgz", + "integrity": "sha1-XjqzIlH/0VOKH45f+hNXdy+S2W8=", + "dev": true, + "requires": { + "d": "1.0.0", + "es5-ext": "0.10.35", + "es6-iterator": "2.0.3", + "es6-symbol": "3.1.1" + } + }, + "escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=", + "dev": true + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true + }, + "escodegen": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.9.0.tgz", + "integrity": "sha512-v0MYvNQ32bzwoG2OSFzWAkuahDQHK92JBN0pTAALJ4RIxEZe766QJPDR8Hqy7XNUy5K3fnVL76OqYAdc4TZEIw==", "dev": true, "requires": { "esprima": "3.1.3", @@ -2763,56 +3206,94 @@ } }, "eslint": { - "version": "3.19.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-3.19.0.tgz", - "integrity": "sha1-yPxiAcf0DdCJQbh8CFdnOGpnmsw=", + "version": "4.10.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-4.10.0.tgz", + "integrity": "sha512-MMVl8P/dYUFZEvolL8PYt7qc5LNdS2lwheq9BYa5Y07FblhcZqFyaUqlS8TW5QITGex21tV4Lk0a3fK8lsJIkA==", "dev": true, "requires": { + "ajv": "5.3.0", "babel-code-frame": "6.26.0", - "chalk": "1.1.3", - "concat-stream": "1.5.2", - "debug": "2.6.9", + "chalk": "2.3.0", + "concat-stream": "1.6.0", + "cross-spawn": "5.1.0", + "debug": "3.1.0", "doctrine": "2.0.0", - "escope": "3.6.0", + "eslint-scope": "3.7.1", "espree": "3.5.1", "esquery": "1.0.0", "estraverse": "4.2.0", "esutils": "2.0.2", "file-entry-cache": "2.0.0", + "functional-red-black-tree": "1.0.1", "glob": "7.1.2", "globals": "9.18.0", - "ignore": "3.3.5", + "ignore": "3.3.7", "imurmurhash": "0.1.4", - "inquirer": "0.12.0", - "is-my-json-valid": "2.16.1", + "inquirer": "3.3.0", "is-resolvable": "1.0.0", "js-yaml": "3.10.0", "json-stable-stringify": "1.0.1", "levn": "0.3.0", "lodash": "4.17.4", + "minimatch": "3.0.4", "mkdirp": "0.5.1", "natural-compare": "1.4.0", "optionator": "0.8.2", "path-is-inside": "1.0.2", - "pluralize": "1.2.1", - "progress": "1.1.8", + "pluralize": "7.0.0", + "progress": "2.0.0", "require-uncached": "1.0.3", - "shelljs": "0.7.8", - "strip-bom": "3.0.0", + "semver": "5.4.1", + "strip-ansi": "4.0.0", "strip-json-comments": "2.0.1", - "table": "3.8.3", - "text-table": "0.2.0", - "user-home": "2.0.0" + "table": "4.0.2", + "text-table": "0.2.0" }, "dependencies": { - "doctrine": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.0.0.tgz", - "integrity": "sha1-xz2NKQnSIpHhoAejlYBNqLZl/mM=", - "dev": true, - "requires": { - "esutils": "2.0.2", - "isarray": "1.0.0" + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "ansi-styles": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", + "integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==", + "dev": true, + "requires": { + "color-convert": "1.9.1" + } + }, + "chalk": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz", + "integrity": "sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q==", + "dev": true, + "requires": { + "ansi-styles": "3.2.0", + "escape-string-regexp": "1.0.5", + "supports-color": "4.5.0" + } + }, + "concat-stream": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.0.tgz", + "integrity": "sha1-CqxmL9Ur54lk1VMvaUeE5wEQrPc=", + "dev": true, + "requires": { + "inherits": "2.0.3", + "readable-stream": "2.3.3", + "typedarray": "0.0.6" + } + }, + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "dev": true, + "requires": { + "ms": "2.0.0" } }, "json-stable-stringify": { @@ -2824,34 +3305,61 @@ "jsonify": "0.0.0" } }, - "strip-bom": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", - "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", - "dev": true + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "3.0.0" + } }, - "user-home": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/user-home/-/user-home-2.0.0.tgz", - "integrity": "sha1-nHC/2Babwdy/SGBODwS4tJzenp8=", + "supports-color": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz", + "integrity": "sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=", "dev": true, "requires": { - "os-homedir": "1.0.2" + "has-flag": "2.0.0" } } } }, + "eslint-config-google": { + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/eslint-config-google/-/eslint-config-google-0.9.1.tgz", + "integrity": "sha512-5A83D+lH0PA81QMESKbLJd/a3ic8tPZtwUmqNrxMRo54nfFaUvtt89q/+icQ+fd66c2xQHn0KyFkzJDoAUfpZA==", + "dev": true + }, + "eslint-config-liferay": { + "version": "2.0.9", + "resolved": "https://registry.npmjs.org/eslint-config-liferay/-/eslint-config-liferay-2.0.9.tgz", + "integrity": "sha512-SgAioMe/7JurwuSH6eiEXdnD/tzaPHtTotbQvzAXrPsXTOFYVE4gc6ZyuW6DootqDZrH+TCz+9UJmnCgSqxarA==", + "dev": true, + "requires": { + "eslint-config-google": "0.9.1" + } + }, "eslint-plugin-react": { - "version": "6.10.3", - "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-6.10.3.tgz", - "integrity": "sha1-xUNb6wZ3ThLH2y9qut3L+QDNP3g=", + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.4.0.tgz", + "integrity": "sha512-tvjU9u3VqmW2vVuYnE8Qptq+6ji4JltjOjJ9u7VAOxVYkUkyBZWRvNYKbDv5fN+L6wiA+4we9+qQahZ0m63XEA==", "dev": true, "requires": { - "array.prototype.find": "2.0.4", - "doctrine": "1.5.0", + "doctrine": "2.0.0", "has": "1.0.1", - "jsx-ast-utils": "1.4.1", - "object.assign": "4.0.4" + "jsx-ast-utils": "2.0.1", + "prop-types": "15.6.0" + } + }, + "eslint-scope": { + "version": "3.7.1", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-3.7.1.tgz", + "integrity": "sha1-PWPD7f2gLgbgGkUq2IyqzHzctug=", + "dev": true, + "requires": { + "esrecurse": "4.2.0", + "estraverse": "4.2.0" } }, "espree": { @@ -2860,14 +3368,14 @@ "integrity": "sha1-DJiLirRttTEAoZVK5LqZXd0n2H4=", "dev": true, "requires": { - "acorn": "5.1.2", + "acorn": "5.2.1", "acorn-jsx": "3.0.1" }, "dependencies": { "acorn": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.1.2.tgz", - "integrity": "sha512-o96FZLJBPY1lvTuJylGA9Bk3t/GKPPJG8H0ydQQl01crzwJgspa4AEIq/pVTXigmK0PHVQhiAtn8WMBLL9D2WA==", + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.2.1.tgz", + "integrity": "sha512-jG0u7c4Ly+3QkkW18V+NRDN+4bWHdln30NL1ZL2AvFZZmQe/BfopYCtghCKKVBUSetZ4QKcyA0pY6/4Gw8Pv8w==", "dev": true } } @@ -2916,7 +3424,7 @@ "dev": true, "requires": { "d": "1.0.0", - "es5-ext": "0.10.31" + "es5-ext": "0.10.35" } }, "eventemitter3": { @@ -3061,25 +3569,8 @@ "dev": true, "requires": { "iconv-lite": "0.4.19", - "jschardet": "1.5.1", + "jschardet": "1.6.0", "tmp": "0.0.33" - }, - "dependencies": { - "iconv-lite": { - "version": "0.4.19", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz", - "integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ==", - "dev": true - }, - "tmp": { - "version": "0.0.33", - "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", - "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", - "dev": true, - "requires": { - "os-tmpdir": "1.0.2" - } - } } }, "extglob": { @@ -3113,20 +3604,48 @@ "integrity": "sha1-liVqO8l1WV6zbYLpkp0GDYk0Of8=", "dev": true }, + "fast-json-stable-stringify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", + "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=", + "dev": true + }, "fast-levenshtein": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", "dev": true }, + "fbjs": { + "version": "0.8.16", + "resolved": "https://registry.npmjs.org/fbjs/-/fbjs-0.8.16.tgz", + "integrity": "sha1-XmdDL1UNxBtXK/VYR7ispk5TN9s=", + "dev": true, + "requires": { + "core-js": "1.2.7", + "isomorphic-fetch": "2.2.1", + "loose-envify": "1.3.1", + "object-assign": "4.1.1", + "promise": "7.3.1", + "setimmediate": "1.0.5", + "ua-parser-js": "0.7.17" + }, + "dependencies": { + "core-js": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-1.2.7.tgz", + "integrity": "sha1-ZSKUwUZR2yj6k70tX/KYOk8IxjY=", + "dev": true + } + } + }, "figures": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/figures/-/figures-1.7.0.tgz", - "integrity": "sha1-y+Hjr/zxzUS4DK3+0o3Hk6lwHS4=", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", + "integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=", "dev": true, "requires": { - "escape-string-regexp": "1.0.5", - "object-assign": "4.1.1" + "escape-string-regexp": "1.0.5" } }, "file-entry-cache": { @@ -3171,6 +3690,14 @@ "parseurl": "1.3.2", "statuses": "1.3.1", "unpipe": "1.0.0" + }, + "dependencies": { + "statuses": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz", + "integrity": "sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4=", + "dev": true + } } }, "find-index": { @@ -3327,18 +3854,923 @@ "jsonfile": "2.4.0" } }, - "fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", - "dev": true - }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "fsevents": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.1.2.tgz", + "integrity": "sha512-Sn44E5wQW4bTHXvQmvSHwqbuiXtduD6Rrjm2ZtUEGbyrig+nUH3t/QD4M4/ZXViY556TBpRgZkHLDx3JxPwxiw==", + "dev": true, + "optional": true, + "requires": { + "nan": "2.7.0", + "node-pre-gyp": "0.6.36" + }, + "dependencies": { + "abbrev": { + "version": "1.1.0", + "bundled": true, + "dev": true, + "optional": true + }, + "ajv": { + "version": "4.11.8", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "co": "4.6.0", + "json-stable-stringify": "1.0.1" + } + }, + "ansi-regex": { + "version": "2.1.1", + "bundled": true, + "dev": true + }, + "aproba": { + "version": "1.1.1", + "bundled": true, + "dev": true, + "optional": true + }, + "are-we-there-yet": { + "version": "1.1.4", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "delegates": "1.0.0", + "readable-stream": "2.2.9" + } + }, + "asn1": { + "version": "0.2.3", + "bundled": true, + "dev": true, + "optional": true + }, + "assert-plus": { + "version": "0.2.0", + "bundled": true, + "dev": true, + "optional": true + }, + "asynckit": { + "version": "0.4.0", + "bundled": true, + "dev": true, + "optional": true + }, + "aws-sign2": { + "version": "0.6.0", + "bundled": true, + "dev": true, + "optional": true + }, + "aws4": { + "version": "1.6.0", + "bundled": true, + "dev": true, + "optional": true + }, + "balanced-match": { + "version": "0.4.2", + "bundled": true, + "dev": true + }, + "bcrypt-pbkdf": { + "version": "1.0.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "tweetnacl": "0.14.5" + } + }, + "block-stream": { + "version": "0.0.9", + "bundled": true, + "dev": true, + "requires": { + "inherits": "2.0.3" + } + }, + "boom": { + "version": "2.10.1", + "bundled": true, + "dev": true, + "requires": { + "hoek": "2.16.3" + } + }, + "brace-expansion": { + "version": "1.1.7", + "bundled": true, + "dev": true, + "requires": { + "balanced-match": "0.4.2", + "concat-map": "0.0.1" + } + }, + "buffer-shims": { + "version": "1.0.0", + "bundled": true, + "dev": true + }, + "caseless": { + "version": "0.12.0", + "bundled": true, + "dev": true, + "optional": true + }, + "co": { + "version": "4.6.0", + "bundled": true, + "dev": true, + "optional": true + }, + "code-point-at": { + "version": "1.1.0", + "bundled": true, + "dev": true + }, + "combined-stream": { + "version": "1.0.5", + "bundled": true, + "dev": true, + "requires": { + "delayed-stream": "1.0.0" + } + }, + "concat-map": { + "version": "0.0.1", + "bundled": true, + "dev": true + }, + "console-control-strings": { + "version": "1.1.0", + "bundled": true, + "dev": true + }, + "core-util-is": { + "version": "1.0.2", + "bundled": true, + "dev": true + }, + "cryptiles": { + "version": "2.0.5", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "boom": "2.10.1" + } + }, + "dashdash": { + "version": "1.14.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "assert-plus": "1.0.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + } + } + }, + "debug": { + "version": "2.6.8", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "ms": "2.0.0" + } + }, + "deep-extend": { + "version": "0.4.2", + "bundled": true, + "dev": true, + "optional": true + }, + "delayed-stream": { + "version": "1.0.0", + "bundled": true, + "dev": true + }, + "delegates": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "ecc-jsbn": { + "version": "0.1.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "jsbn": "0.1.1" + } + }, + "extend": { + "version": "3.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "extsprintf": { + "version": "1.0.2", + "bundled": true, + "dev": true + }, + "forever-agent": { + "version": "0.6.1", + "bundled": true, + "dev": true, + "optional": true + }, + "form-data": { + "version": "2.1.4", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "asynckit": "0.4.0", + "combined-stream": "1.0.5", + "mime-types": "2.1.15" + } + }, + "fs.realpath": { + "version": "1.0.0", + "bundled": true, + "dev": true + }, + "fstream": { + "version": "1.0.11", + "bundled": true, + "dev": true, + "requires": { + "graceful-fs": "4.1.11", + "inherits": "2.0.3", + "mkdirp": "0.5.1", + "rimraf": "2.6.1" + } + }, + "fstream-ignore": { + "version": "1.0.5", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "fstream": "1.0.11", + "inherits": "2.0.3", + "minimatch": "3.0.4" + } + }, + "gauge": { + "version": "2.7.4", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "aproba": "1.1.1", + "console-control-strings": "1.1.0", + "has-unicode": "2.0.1", + "object-assign": "4.1.1", + "signal-exit": "3.0.2", + "string-width": "1.0.2", + "strip-ansi": "3.0.1", + "wide-align": "1.1.2" + } + }, + "getpass": { + "version": "0.1.7", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "assert-plus": "1.0.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + } + } + }, + "glob": { + "version": "7.1.2", + "bundled": true, + "dev": true, + "requires": { + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" + } + }, + "graceful-fs": { + "version": "4.1.11", + "bundled": true, + "dev": true + }, + "har-schema": { + "version": "1.0.5", + "bundled": true, + "dev": true, + "optional": true + }, + "har-validator": { + "version": "4.2.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "ajv": "4.11.8", + "har-schema": "1.0.5" + } + }, + "has-unicode": { + "version": "2.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "hawk": { + "version": "3.1.3", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "boom": "2.10.1", + "cryptiles": "2.0.5", + "hoek": "2.16.3", + "sntp": "1.0.9" + } + }, + "hoek": { + "version": "2.16.3", + "bundled": true, + "dev": true + }, + "http-signature": { + "version": "1.1.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "assert-plus": "0.2.0", + "jsprim": "1.4.0", + "sshpk": "1.13.0" + } + }, + "inflight": { + "version": "1.0.6", + "bundled": true, + "dev": true, + "requires": { + "once": "1.4.0", + "wrappy": "1.0.2" + } + }, + "inherits": { + "version": "2.0.3", + "bundled": true, + "dev": true + }, + "ini": { + "version": "1.3.4", + "bundled": true, + "dev": true, + "optional": true + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "requires": { + "number-is-nan": "1.0.1" + } + }, + "is-typedarray": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "isarray": { + "version": "1.0.0", + "bundled": true, + "dev": true + }, + "isstream": { + "version": "0.1.2", + "bundled": true, + "dev": true, + "optional": true + }, + "jodid25519": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "jsbn": "0.1.1" + } + }, + "jsbn": { + "version": "0.1.1", + "bundled": true, + "dev": true, + "optional": true + }, + "json-schema": { + "version": "0.2.3", + "bundled": true, + "dev": true, + "optional": true + }, + "json-stable-stringify": { + "version": "1.0.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "jsonify": "0.0.0" + } + }, + "json-stringify-safe": { + "version": "5.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "jsonify": { + "version": "0.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "jsprim": { + "version": "1.4.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "assert-plus": "1.0.0", + "extsprintf": "1.0.2", + "json-schema": "0.2.3", + "verror": "1.3.6" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + } + } + }, + "mime-db": { + "version": "1.27.0", + "bundled": true, + "dev": true + }, + "mime-types": { + "version": "2.1.15", + "bundled": true, + "dev": true, + "requires": { + "mime-db": "1.27.0" + } + }, + "minimatch": { + "version": "3.0.4", + "bundled": true, + "dev": true, + "requires": { + "brace-expansion": "1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "bundled": true, + "dev": true + }, + "mkdirp": { + "version": "0.5.1", + "bundled": true, + "dev": true, + "requires": { + "minimist": "0.0.8" + } + }, + "ms": { + "version": "2.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "node-pre-gyp": { + "version": "0.6.36", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "mkdirp": "0.5.1", + "nopt": "4.0.1", + "npmlog": "4.1.0", + "rc": "1.2.1", + "request": "2.81.0", + "rimraf": "2.6.1", + "semver": "5.3.0", + "tar": "2.2.1", + "tar-pack": "3.4.0" + } + }, + "nopt": { + "version": "4.0.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "abbrev": "1.1.0", + "osenv": "0.1.4" + } + }, + "npmlog": { + "version": "4.1.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "are-we-there-yet": "1.1.4", + "console-control-strings": "1.1.0", + "gauge": "2.7.4", + "set-blocking": "2.0.0" + } + }, + "number-is-nan": { + "version": "1.0.1", + "bundled": true, + "dev": true + }, + "oauth-sign": { + "version": "0.8.2", + "bundled": true, + "dev": true, + "optional": true + }, + "object-assign": { + "version": "4.1.1", + "bundled": true, + "dev": true, + "optional": true + }, + "once": { + "version": "1.4.0", + "bundled": true, + "dev": true, + "requires": { + "wrappy": "1.0.2" + } + }, + "os-homedir": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "os-tmpdir": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "osenv": { + "version": "0.1.4", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "os-homedir": "1.0.2", + "os-tmpdir": "1.0.2" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "bundled": true, + "dev": true + }, + "performance-now": { + "version": "0.2.0", + "bundled": true, + "dev": true, + "optional": true + }, + "process-nextick-args": { + "version": "1.0.7", + "bundled": true, + "dev": true + }, + "punycode": { + "version": "1.4.1", + "bundled": true, + "dev": true, + "optional": true + }, + "qs": { + "version": "6.4.0", + "bundled": true, + "dev": true, + "optional": true + }, + "rc": { + "version": "1.2.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "deep-extend": "0.4.2", + "ini": "1.3.4", + "minimist": "1.2.0", + "strip-json-comments": "2.0.1" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "bundled": true, + "dev": true, + "optional": true + } + } + }, + "readable-stream": { + "version": "2.2.9", + "bundled": true, + "dev": true, + "requires": { + "buffer-shims": "1.0.0", + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "1.0.7", + "string_decoder": "1.0.1", + "util-deprecate": "1.0.2" + } + }, + "request": { + "version": "2.81.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "aws-sign2": "0.6.0", + "aws4": "1.6.0", + "caseless": "0.12.0", + "combined-stream": "1.0.5", + "extend": "3.0.1", + "forever-agent": "0.6.1", + "form-data": "2.1.4", + "har-validator": "4.2.1", + "hawk": "3.1.3", + "http-signature": "1.1.1", + "is-typedarray": "1.0.0", + "isstream": "0.1.2", + "json-stringify-safe": "5.0.1", + "mime-types": "2.1.15", + "oauth-sign": "0.8.2", + "performance-now": "0.2.0", + "qs": "6.4.0", + "safe-buffer": "5.0.1", + "stringstream": "0.0.5", + "tough-cookie": "2.3.2", + "tunnel-agent": "0.6.0", + "uuid": "3.0.1" + } + }, + "rimraf": { + "version": "2.6.1", + "bundled": true, + "dev": true, + "requires": { + "glob": "7.1.2" + } + }, + "safe-buffer": { + "version": "5.0.1", + "bundled": true, + "dev": true + }, + "semver": { + "version": "5.3.0", + "bundled": true, + "dev": true, + "optional": true + }, + "set-blocking": { + "version": "2.0.0", + "bundled": true, + "dev": true, + "optional": true + }, + "signal-exit": { + "version": "3.0.2", + "bundled": true, + "dev": true, + "optional": true + }, + "sntp": { + "version": "1.0.9", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "hoek": "2.16.3" + } + }, + "sshpk": { + "version": "1.13.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "asn1": "0.2.3", + "assert-plus": "1.0.0", + "bcrypt-pbkdf": "1.0.1", + "dashdash": "1.14.1", + "ecc-jsbn": "0.1.1", + "getpass": "0.1.7", + "jodid25519": "1.0.2", + "jsbn": "0.1.1", + "tweetnacl": "0.14.5" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "optional": true + } + } + }, + "string-width": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "requires": { + "code-point-at": "1.1.0", + "is-fullwidth-code-point": "1.0.0", + "strip-ansi": "3.0.1" + } + }, + "string_decoder": { + "version": "1.0.1", + "bundled": true, + "dev": true, + "requires": { + "safe-buffer": "5.0.1" + } + }, + "stringstream": { + "version": "0.0.5", + "bundled": true, + "dev": true, + "optional": true + }, + "strip-ansi": { + "version": "3.0.1", + "bundled": true, + "dev": true, + "requires": { + "ansi-regex": "2.1.1" + } + }, + "strip-json-comments": { + "version": "2.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "tar": { + "version": "2.2.1", + "bundled": true, + "dev": true, + "requires": { + "block-stream": "0.0.9", + "fstream": "1.0.11", + "inherits": "2.0.3" + } + }, + "tar-pack": { + "version": "3.4.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "debug": "2.6.8", + "fstream": "1.0.11", + "fstream-ignore": "1.0.5", + "once": "1.4.0", + "readable-stream": "2.2.9", + "rimraf": "2.6.1", + "tar": "2.2.1", + "uid-number": "0.0.6" + } + }, + "tough-cookie": { + "version": "2.3.2", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "punycode": "1.4.1" + } + }, + "tunnel-agent": { + "version": "0.6.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "safe-buffer": "5.0.1" + } + }, + "tweetnacl": { + "version": "0.14.5", + "bundled": true, + "dev": true, + "optional": true + }, + "uid-number": { + "version": "0.0.6", + "bundled": true, + "dev": true, + "optional": true + }, + "util-deprecate": { + "version": "1.0.2", + "bundled": true, + "dev": true + }, + "uuid": { + "version": "3.0.1", + "bundled": true, + "dev": true, + "optional": true + }, + "verror": { + "version": "1.3.6", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "extsprintf": "1.0.2" + } + }, + "wide-align": { + "version": "1.1.2", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "string-width": "1.0.2" + } + }, + "wrappy": { + "version": "1.0.2", + "bundled": true, + "dev": true + } + } + }, "function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", "dev": true }, + "functional-red-black-tree": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", + "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", + "dev": true + }, "gauge": { "version": "2.7.4", "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz", @@ -3353,6 +4785,28 @@ "string-width": "1.0.2", "strip-ansi": "3.0.1", "wide-align": "1.1.2" + }, + "dependencies": { + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "dev": true, + "requires": { + "number-is-nan": "1.0.1" + } + }, + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "dev": true, + "requires": { + "code-point-at": "1.1.0", + "is-fullwidth-code-point": "1.0.0", + "strip-ansi": "3.0.1" + } + } } }, "gaze": { @@ -3385,6 +4839,12 @@ "integrity": "sha1-9wLmMSfn4jHBYKgMFVSstw1QR+U=", "dev": true }, + "get-own-enumerable-property-symbols": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/get-own-enumerable-property-symbols/-/get-own-enumerable-property-symbols-2.0.1.tgz", + "integrity": "sha512-TtY/sbOemiMKPRUDDanGCSgBYe7Mf0vbRsWnBZ+9yghpZ1MvcpSpuZFjHdEeY/LZjZy0vdLjS77L6HosisFiug==", + "dev": true + }, "get-pkg-repo": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/get-pkg-repo/-/get-pkg-repo-1.4.0.tgz", @@ -3725,6 +5185,12 @@ "integrity": "sha1-j1dWDIO1n8JwvT1WG2kAQ0MOJVE=", "dev": true }, + "lru-cache": { + "version": "2.7.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.7.3.tgz", + "integrity": "sha1-bUUk6LlV+V1PW1iFHOId1y+06VI=", + "dev": true + }, "minimatch": { "version": "0.2.14", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-0.2.14.tgz", @@ -3746,6 +5212,25 @@ "sparkles": "1.0.0" } }, + "got": { + "version": "6.7.1", + "resolved": "https://registry.npmjs.org/got/-/got-6.7.1.tgz", + "integrity": "sha1-JAzQV4WpoY5WHcG0S0HHY+8ejbA=", + "dev": true, + "requires": { + "create-error-class": "3.0.2", + "duplexer3": "0.1.4", + "get-stream": "3.0.0", + "is-redirect": "1.0.0", + "is-retry-allowed": "1.1.0", + "is-stream": "1.1.0", + "lowercase-keys": "1.0.0", + "safe-buffer": "5.1.1", + "timed-out": "4.0.1", + "unzip-response": "2.0.1", + "url-parse-lax": "1.0.0" + } + }, "graceful-fs": { "version": "4.1.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", @@ -5020,6 +6505,7 @@ "requires": { "anymatch": "1.3.0", "async-each": "1.0.1", + "fsevents": "1.1.2", "glob-parent": "2.0.0", "inherits": "2.0.3", "is-binary-path": "1.0.1", @@ -5776,7 +7262,8 @@ "esprima": "2.7.3", "estraverse": "1.9.3", "esutils": "2.0.2", - "optionator": "0.8.2" + "optionator": "0.8.2", + "source-map": "0.2.0" }, "dependencies": { "esprima": { @@ -5788,6 +7275,16 @@ "version": "1.9.3", "bundled": true, "dev": true + }, + "source-map": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.2.0.tgz", + "integrity": "sha1-2rc/vPwrqBm03gO9b26qSBZLP50=", + "dev": true, + "optional": true, + "requires": { + "amdefine": "1.0.1" + } } } }, @@ -10097,8 +11594,12 @@ "requires": { "asn1": "0.2.3", "assert-plus": "1.0.0", + "bcrypt-pbkdf": "1.0.1", "dashdash": "1.14.1", - "getpass": "0.1.7" + "ecc-jsbn": "0.1.1", + "getpass": "0.1.7", + "jsbn": "0.1.1", + "tweetnacl": "0.14.5" }, "dependencies": { "assert-plus": { @@ -10137,14 +11638,6 @@ "bundled": true, "dev": true }, - "string_decoder": { - "version": "1.0.2", - "bundled": true, - "dev": true, - "requires": { - "safe-buffer": "5.0.1" - } - }, "string-length": { "version": "1.0.1", "bundled": true, @@ -10163,6 +11656,14 @@ "strip-ansi": "3.0.1" } }, + "string_decoder": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "requires": { + "safe-buffer": "5.0.1" + } + }, "stringstream": { "version": "0.0.5", "bundled": true, @@ -11052,7 +12553,7 @@ "integrity": "sha1-XIgDbPVl5d8FVYv8kR+GVt8hiIQ=", "dev": true, "requires": { - "clone": "1.0.2", + "clone": "1.0.3", "clone-stats": "0.0.1", "replace-ext": "0.0.1" } @@ -11149,14 +12650,15 @@ } }, "handlebars": { - "version": "4.0.10", - "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.0.10.tgz", - "integrity": "sha1-PTDHGLCaPZbyPqTMH0A8TTup/08=", + "version": "4.0.11", + "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.0.11.tgz", + "integrity": "sha1-Ywo13+ApS8KB7a5v/F0yn8eYLcw=", "dev": true, "requires": { "async": "1.5.2", "optimist": "0.6.1", - "source-map": "0.4.4" + "source-map": "0.4.4", + "uglify-js": "2.8.29" }, "dependencies": { "source-map": { @@ -11182,31 +12684,8 @@ "integrity": "sha1-ukAsJmGU8VlW7xXg/PJCmT9qff0=", "dev": true, "requires": { - "ajv": "5.2.3", + "ajv": "5.3.0", "har-schema": "2.0.0" - }, - "dependencies": { - "ajv": { - "version": "5.2.3", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.2.3.tgz", - "integrity": "sha1-wG9Zh3jETGsWGrr+NGa4GtGBTtI=", - "dev": true, - "requires": { - "co": "4.6.0", - "fast-deep-equal": "1.0.0", - "json-schema-traverse": "0.3.1", - "json-stable-stringify": "1.0.1" - } - }, - "json-stable-stringify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", - "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", - "dev": true, - "requires": { - "jsonify": "0.0.0" - } - } } }, "has": { @@ -11251,9 +12730,9 @@ "dev": true }, "has-flag": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz", - "integrity": "sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo=", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", + "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", "dev": true }, "has-gulplog": { @@ -11305,7 +12784,7 @@ "boom": "4.3.1", "cryptiles": "3.1.2", "hoek": "4.2.0", - "sntp": "2.0.2" + "sntp": "2.1.0" } }, "hmac-drbg": { @@ -11351,12 +12830,12 @@ "dev": true }, "html-encoding-sniffer": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-1.0.1.tgz", - "integrity": "sha1-eb96eF6klf5mFl5zQVPzY/9UN9o=", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-1.0.2.tgz", + "integrity": "sha512-71lZziiDnsuabfdYiUeWdCVyKuqwWi23L8YeIgV9jSSZHCtb6wB1BKWooH7L3tn4/FuZJMVWyNaIDr4RGmaSYw==", "dev": true, "requires": { - "whatwg-encoding": "1.0.1" + "whatwg-encoding": "1.0.3" } }, "htmlescape": { @@ -11374,7 +12853,7 @@ "depd": "1.1.1", "inherits": "2.0.3", "setprototypeof": "1.0.3", - "statuses": "1.3.1" + "statuses": "1.4.0" } }, "http-proxy": { @@ -11404,10 +12883,35 @@ "integrity": "sha1-P5E2XKvmC3ftDruiS0VOPgnZWoI=", "dev": true }, + "husky": { + "version": "0.14.3", + "resolved": "https://registry.npmjs.org/husky/-/husky-0.14.3.tgz", + "integrity": "sha512-e21wivqHpstpoiWA/Yi8eFti8E+sQDSS53cpJsPptPs295QTOQR0ZwnHo2TXy1XOpZFD9rPOd3NpmqTK6uMLJA==", + "dev": true, + "requires": { + "is-ci": "1.0.10", + "normalize-path": "1.0.0", + "strip-indent": "2.0.0" + }, + "dependencies": { + "normalize-path": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-1.0.0.tgz", + "integrity": "sha1-MtDkcvkf80VwHBWoMRAY07CpA3k=", + "dev": true + }, + "strip-indent": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-2.0.0.tgz", + "integrity": "sha1-XvjbKV0B5u1sv3qrlpmNeCJSe2g=", + "dev": true + } + } + }, "iconv-lite": { - "version": "0.4.13", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.13.tgz", - "integrity": "sha1-H4irpKsLFQjoMSrMOTRfNumS4vI=", + "version": "0.4.19", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz", + "integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ==", "dev": true }, "ieee754": { @@ -11417,9 +12921,9 @@ "dev": true }, "ignore": { - "version": "3.3.5", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.5.tgz", - "integrity": "sha512-JLH93mL8amZQhh/p6mfQgVBH3M6epNq3DfsXsTSuSrInVjwyYlFE1nv2AgfRCC8PoOhM0jwQ5v8s9LgbK7yGDw==", + "version": "3.3.7", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.7.tgz", + "integrity": "sha512-YGG3ejvBNHRqu0559EOxxNFihD0AjpvHlC/pdGKd3X3ofe+CoJkYazwNJYTNebqpPKN+VVQbh4ZFn1DivMNuHA==", "dev": true }, "imurmurhash": { @@ -11475,24 +12979,71 @@ } }, "inquirer": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-0.12.0.tgz", - "integrity": "sha1-HvK/1jUE3wvHV4X/+MLEHfEvB34=", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-3.3.0.tgz", + "integrity": "sha512-h+xtnyk4EwKvFWHrUYsWErEVR+igKtLdchu+o0Z1RL7VU/jVMFbYir2bp6bAj8efFNxWqHX0dIss6fJQ+/+qeQ==", "dev": true, "requires": { - "ansi-escapes": "1.4.0", - "ansi-regex": "2.1.1", - "chalk": "1.1.3", - "cli-cursor": "1.0.2", + "ansi-escapes": "3.0.0", + "chalk": "2.3.0", + "cli-cursor": "2.1.0", "cli-width": "2.2.0", - "figures": "1.7.0", + "external-editor": "2.0.5", + "figures": "2.0.0", "lodash": "4.17.4", - "readline2": "1.0.1", - "run-async": "0.1.0", - "rx-lite": "3.1.2", - "string-width": "1.0.2", - "strip-ansi": "3.0.1", + "mute-stream": "0.0.7", + "run-async": "2.3.0", + "rx-lite": "4.0.8", + "rx-lite-aggregates": "4.0.8", + "string-width": "2.1.1", + "strip-ansi": "4.0.0", "through": "2.3.8" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "ansi-styles": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", + "integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==", + "dev": true, + "requires": { + "color-convert": "1.9.1" + } + }, + "chalk": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz", + "integrity": "sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q==", + "dev": true, + "requires": { + "ansi-styles": "3.2.0", + "escape-string-regexp": "1.0.5", + "supports-color": "4.5.0" + } + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "3.0.0" + } + }, + "supports-color": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz", + "integrity": "sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=", + "dev": true, + "requires": { + "has-flag": "2.0.0" + } + } } }, "insert-module-globals": { @@ -11501,10 +13052,10 @@ "integrity": "sha1-wDv04BywhtW15azorQr+eInWOMM=", "dev": true, "requires": { + "JSONStream": "1.3.1", "combine-source-map": "0.7.2", "concat-stream": "1.5.2", - "is-buffer": "1.1.5", - "JSONStream": "1.3.1", + "is-buffer": "1.1.6", "lexical-scope": "1.2.0", "process": "0.11.10", "through2": "2.0.3", @@ -11558,9 +13109,9 @@ } }, "is-buffer": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.5.tgz", - "integrity": "sha1-Hzsm72E7IUuIy8ojzGwB2Hlh7sw=", + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, "is-builtin-module": { @@ -11630,13 +13181,10 @@ } }, "is-fullwidth-code-point": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", - "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", - "dev": true, - "requires": { - "number-is-nan": "1.0.1" - } + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true }, "is-glob": { "version": "2.0.1", @@ -11745,6 +13293,12 @@ "integrity": "sha1-V/4cTkhHTt1lsJkR8msc1Ald2oQ=", "dev": true }, + "is-redirect": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-redirect/-/is-redirect-1.0.0.tgz", + "integrity": "sha1-HQPd7VO9jbDzDCbk+V02/HyH3CQ=", + "dev": true + }, "is-regex": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz", @@ -11754,6 +13308,12 @@ "has": "1.0.1" } }, + "is-regexp": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-regexp/-/is-regexp-1.0.0.tgz", + "integrity": "sha1-/S2INUXEa6xaYz57mgnof6LLUGk=", + "dev": true + }, "is-relative": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/is-relative/-/is-relative-0.2.1.tgz", @@ -11772,6 +13332,12 @@ "tryit": "1.0.3" } }, + "is-retry-allowed": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-retry-allowed/-/is-retry-allowed-1.1.0.tgz", + "integrity": "sha1-EaBgVotnM5REAz0BJaYaINVk+zQ=", + "dev": true + }, "is-stream": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", @@ -11859,6 +13425,16 @@ "isarray": "1.0.0" } }, + "isomorphic-fetch": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz", + "integrity": "sha1-YRrhrPFPXoH3KVB0coGf6XM1WKk=", + "dev": true, + "requires": { + "node-fetch": "1.7.3", + "whatwg-fetch": "2.0.3" + } + }, "isstream": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", @@ -11876,7 +13452,7 @@ "escodegen": "1.8.1", "esprima": "2.7.3", "glob": "5.0.15", - "handlebars": "4.0.10", + "handlebars": "4.0.11", "js-yaml": "3.10.0", "mkdirp": "0.5.1", "nopt": "3.0.6", @@ -11896,7 +13472,8 @@ "esprima": "2.7.3", "estraverse": "1.9.3", "esutils": "2.0.2", - "optionator": "0.8.2" + "optionator": "0.8.2", + "source-map": "0.2.0" } }, "esprima": { @@ -11924,12 +13501,28 @@ "path-is-absolute": "1.0.1" } }, + "has-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz", + "integrity": "sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo=", + "dev": true + }, "resolve": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz", "integrity": "sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=", "dev": true }, + "source-map": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.2.0.tgz", + "integrity": "sha1-2rc/vPwrqBm03gO9b26qSBZLP50=", + "dev": true, + "optional": true, + "requires": { + "amdefine": "1.0.1" + } + }, "supports-color": { "version": "3.2.3", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.2.3.tgz", @@ -11948,9 +13541,9 @@ "dev": true }, "istanbul-lib-instrument": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-1.8.0.tgz", - "integrity": "sha1-ZvbJQhzJ7EcE928tsIS6kHiitTI=", + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-1.9.1.tgz", + "integrity": "sha512-RQmXeQ7sphar7k7O1wTNzVczF9igKpaeGQAG9qR2L+BS4DCJNTI9nytRmIVYevwO0bbq+2CXvJmYDuz0gMrywA==", "dev": true, "requires": { "babel-generator": "6.26.0", @@ -11996,6 +13589,71 @@ } } }, + "jest-get-type": { + "version": "21.2.0", + "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-21.2.0.tgz", + "integrity": "sha512-y2fFw3C+D0yjNSDp7ab1kcd6NUYfy3waPTlD8yWkAtiocJdBRQqNoRqVfMNxgj+IjT0V5cBIHJO0z9vuSSZ43Q==", + "dev": true + }, + "jest-validate": { + "version": "21.2.1", + "resolved": "https://registry.npmjs.org/jest-validate/-/jest-validate-21.2.1.tgz", + "integrity": "sha512-k4HLI1rZQjlU+EC682RlQ6oZvLrE5SCh3brseQc24vbZTxzT/k/3urar5QMCVgjadmSO7lECeGdc6YxnM3yEGg==", + "dev": true, + "requires": { + "chalk": "2.3.0", + "jest-get-type": "21.2.0", + "leven": "2.1.0", + "pretty-format": "21.2.1" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "ansi-styles": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", + "integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==", + "dev": true, + "requires": { + "color-convert": "1.9.1" + } + }, + "chalk": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz", + "integrity": "sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q==", + "dev": true, + "requires": { + "ansi-styles": "3.2.0", + "escape-string-regexp": "1.0.5", + "supports-color": "4.5.0" + } + }, + "pretty-format": { + "version": "21.2.1", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-21.2.1.tgz", + "integrity": "sha512-ZdWPGYAnYfcVP8yKA3zFjCn8s4/17TeYH28MXuC8vTp0o21eXjbFGcOAXZEaDaOFJjc3h2qa7HQNHNshhvoh2A==", + "dev": true, + "requires": { + "ansi-regex": "3.0.0", + "ansi-styles": "3.2.0" + } + }, + "supports-color": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz", + "integrity": "sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=", + "dev": true, + "requires": { + "has-flag": "2.0.0" + } + } + } + }, "js-base64": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/js-base64/-/js-base64-2.3.2.tgz", @@ -12024,10 +13682,17 @@ "esprima": "4.0.0" } }, + "jsbn": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", + "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", + "dev": true, + "optional": true + }, "jschardet": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/jschardet/-/jschardet-1.5.1.tgz", - "integrity": "sha512-vE2hT1D0HLZCLLclfBSfkfTTedhVj0fubHpJBHKwwUWX0nSbhPAfk+SG9rTX95BYNmau8rGFfCeaT6T5OW1C2A==", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/jschardet/-/jschardet-1.6.0.tgz", + "integrity": "sha512-xYuhvQ7I9PDJIGBWev9xm0+SMSed3ZDBAmvVjbFR1ZRLAF+vlXcQu6cRI9uAlj81rzikElRVteehwV7DuX2ZmQ==", "dev": true }, "jsdom": { @@ -12040,19 +13705,19 @@ "acorn": "4.0.13", "acorn-globals": "3.1.0", "array-equal": "1.0.0", - "content-type-parser": "1.0.1", + "content-type-parser": "1.0.2", "cssom": "0.3.2", "cssstyle": "0.2.37", "escodegen": "1.9.0", - "html-encoding-sniffer": "1.0.1", - "nwmatcher": "1.4.2", + "html-encoding-sniffer": "1.0.2", + "nwmatcher": "1.4.3", "parse5": "1.5.1", "request": "2.83.0", "sax": "1.2.4", "symbol-tree": "3.2.2", "tough-cookie": "2.3.3", "webidl-conversions": "4.0.2", - "whatwg-encoding": "1.0.1", + "whatwg-encoding": "1.0.3", "whatwg-url": "4.8.0", "xml-name-validator": "2.0.1" } @@ -12135,16 +13800,6 @@ "integrity": "sha1-T9kss04OnbPInIYi7PUfm5eMbLk=", "dev": true }, - "JSONStream": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.1.tgz", - "integrity": "sha1-cH92HgHa6eFvG8+TcDt4xwlmV5o=", - "dev": true, - "requires": { - "jsonparse": "1.3.1", - "through": "2.3.8" - } - }, "jsprim": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", @@ -12158,10 +13813,13 @@ } }, "jsx-ast-utils": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-1.4.1.tgz", - "integrity": "sha1-OGchPo3Xm/Ho8jAMDPwe+xgsDfE=", - "dev": true + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-2.0.1.tgz", + "integrity": "sha1-6AGxs5mF4g//yHtA43SAgOLcrH8=", + "dev": true, + "requires": { + "array-includes": "3.0.3" + } }, "karma": { "version": "1.7.1", @@ -12203,6 +13861,15 @@ "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz", "integrity": "sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y=", "dev": true + }, + "tmp": { + "version": "0.0.31", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.31.tgz", + "integrity": "sha1-jzirlDjhcxXl29izZX6L+yd65Kc=", + "dev": true, + "requires": { + "os-tmpdir": "1.0.2" + } } } }, @@ -12313,7 +13980,7 @@ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "1.1.5" + "is-buffer": "1.1.6" } }, "labeled-stream-splicer": { @@ -12335,6 +14002,13 @@ } } }, + "lazy-cache": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-1.0.4.tgz", + "integrity": "sha1-odePw6UEdMuAhF07O24dpJpEbo4=", + "dev": true, + "optional": true + }, "lazystream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/lazystream/-/lazystream-1.0.0.tgz", @@ -12354,13 +14028,13 @@ } }, "lerna": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/lerna/-/lerna-2.4.0.tgz", - "integrity": "sha512-hpoIS0PuhIUpulMF4sQ/aWLUMoH8x7L5fSKF4cf1oNJhmC5FukTpR5fWe8EzmUszFo6Nj/bdJfN36OYDrEJAOA==", + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/lerna/-/lerna-2.5.1.tgz", + "integrity": "sha512-Qz2fajqCPtZf4SFQQpQ2R/Ml/RvGvTNuIHix/vAMMSAdbtnPe2QTw34vLD24Clfsfy8FEojy+tqsjejWKqkDFw==", "dev": true, "requires": { "async": "1.5.2", - "chalk": "2.1.0", + "chalk": "2.3.0", "cmd-shim": "2.0.2", "columnify": "1.5.4", "command-join": "2.0.0", @@ -12383,6 +14057,7 @@ "minimatch": "3.0.4", "npmlog": "4.1.2", "p-finally": "1.0.0", + "package-json": "4.0.1", "path-exists": "3.0.0", "read-cmd-shim": "1.0.1", "read-pkg": "2.0.0", @@ -12398,54 +14073,24 @@ "yargs": "8.0.2" }, "dependencies": { - "ansi-escapes": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.0.0.tgz", - "integrity": "sha512-O/klc27mWNUigtv0F8NJWbLF00OcegQalkqKURWdosW08YZKi4m6CnSUSvIZG1otNJbTWhN01Hhz389DW7mvDQ==", - "dev": true - }, - "ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", - "dev": true - }, "ansi-styles": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", "integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==", "dev": true, "requires": { - "color-convert": "1.9.0" + "color-convert": "1.9.1" } }, "chalk": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.1.0.tgz", - "integrity": "sha512-LUHGS/dge4ujbXMJrnihYMcL4AoOweGnw9Tp3kQuqy1Kx5c1qKjqvMJZ6nVJPMWJtKCTN72ZogH3oeSO9g9rXQ==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz", + "integrity": "sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q==", "dev": true, "requires": { "ansi-styles": "3.2.0", "escape-string-regexp": "1.0.5", - "supports-color": "4.4.0" - } - }, - "cli-cursor": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", - "integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=", - "dev": true, - "requires": { - "restore-cursor": "2.0.0" - } - }, - "figures": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", - "integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=", - "dev": true, - "requires": { - "escape-string-regexp": "1.0.5" + "supports-color": "4.5.0" } }, "find-up": { @@ -12491,46 +14136,12 @@ "pinkie-promise": "2.0.1" } }, - "has-flag": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", - "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", - "dev": true - }, - "inquirer": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-3.3.0.tgz", - "integrity": "sha512-h+xtnyk4EwKvFWHrUYsWErEVR+igKtLdchu+o0Z1RL7VU/jVMFbYir2bp6bAj8efFNxWqHX0dIss6fJQ+/+qeQ==", - "dev": true, - "requires": { - "ansi-escapes": "3.0.0", - "chalk": "2.1.0", - "cli-cursor": "2.1.0", - "cli-width": "2.2.0", - "external-editor": "2.0.5", - "figures": "2.0.0", - "lodash": "4.17.4", - "mute-stream": "0.0.7", - "run-async": "2.3.0", - "rx-lite": "4.0.8", - "rx-lite-aggregates": "4.0.8", - "string-width": "2.1.1", - "strip-ansi": "4.0.0", - "through": "2.3.8" - } - }, "is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", "dev": true }, - "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", - "dev": true - }, "is-glob": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", @@ -12561,21 +14172,6 @@ "strip-bom": "3.0.0" } }, - "mute-stream": { - "version": "0.0.7", - "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", - "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=", - "dev": true - }, - "onetime": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz", - "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=", - "dev": true, - "requires": { - "mimic-fn": "1.1.0" - } - }, "parse-json": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-3.0.0.tgz", @@ -12634,103 +14230,277 @@ } } }, - "restore-cursor": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", - "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=", + "strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", + "dev": true + }, + "supports-color": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz", + "integrity": "sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=", + "dev": true, + "requires": { + "has-flag": "2.0.0" + } + } + } + }, + "leven": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/leven/-/leven-2.1.0.tgz", + "integrity": "sha1-wuep93IJTe6dNCAq6KzORoeHVYA=", + "dev": true + }, + "levn": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", + "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "dev": true, + "requires": { + "prelude-ls": "1.1.2", + "type-check": "0.3.2" + } + }, + "lexical-scope": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/lexical-scope/-/lexical-scope-1.2.0.tgz", + "integrity": "sha1-/Ope3HBKSzqHls3KQZw6CvryLfQ=", + "dev": true, + "requires": { + "astw": "2.2.0" + } + }, + "liftoff": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/liftoff/-/liftoff-2.3.0.tgz", + "integrity": "sha1-qY8v9nGD2Lp8+soQVIvX/wVQs4U=", + "dev": true, + "requires": { + "extend": "3.0.1", + "findup-sync": "0.4.3", + "fined": "1.1.0", + "flagged-respawn": "0.3.2", + "lodash.isplainobject": "4.0.6", + "lodash.isstring": "4.0.1", + "lodash.mapvalues": "4.6.0", + "rechoir": "0.6.2", + "resolve": "1.5.0" + } + }, + "lint-staged": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-4.3.0.tgz", + "integrity": "sha512-C/Zxslg0VRbsxwmCu977iIs+QyrmW2cyRCPUV5NDFYOH/jtRFHH8ch7ua2fH0voI/nVC3Tpg7DykfgMZySliKw==", + "dev": true, + "requires": { + "app-root-path": "2.0.1", + "chalk": "2.3.0", + "commander": "2.11.0", + "cosmiconfig": "1.1.0", + "execa": "0.8.0", + "is-glob": "4.0.0", + "jest-validate": "21.2.1", + "listr": "0.12.0", + "lodash": "4.17.4", + "log-symbols": "2.1.0", + "minimatch": "3.0.4", + "npm-which": "3.0.1", + "p-map": "1.2.0", + "staged-git-files": "0.0.4", + "stringify-object": "3.2.1" + }, + "dependencies": { + "ansi-styles": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", + "integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==", + "dev": true, + "requires": { + "color-convert": "1.9.1" + } + }, + "chalk": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz", + "integrity": "sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q==", + "dev": true, + "requires": { + "ansi-styles": "3.2.0", + "escape-string-regexp": "1.0.5", + "supports-color": "4.5.0" + } + }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "dev": true + }, + "is-glob": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.0.tgz", + "integrity": "sha1-lSHHaEXMJhCoUgPd8ICpWML/q8A=", + "dev": true, + "requires": { + "is-extglob": "2.1.1" + } + }, + "supports-color": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz", + "integrity": "sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=", + "dev": true, + "requires": { + "has-flag": "2.0.0" + } + } + } + }, + "listr": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/listr/-/listr-0.12.0.tgz", + "integrity": "sha1-a84sD1YD+klYDqF81qAMwOX6RRo=", + "dev": true, + "requires": { + "chalk": "1.1.3", + "cli-truncate": "0.2.1", + "figures": "1.7.0", + "indent-string": "2.1.0", + "is-promise": "2.1.0", + "is-stream": "1.1.0", + "listr-silent-renderer": "1.1.1", + "listr-update-renderer": "0.2.0", + "listr-verbose-renderer": "0.4.1", + "log-symbols": "1.0.2", + "log-update": "1.0.2", + "ora": "0.2.3", + "p-map": "1.2.0", + "rxjs": "5.5.2", + "stream-to-observable": "0.1.0", + "strip-ansi": "3.0.1" + }, + "dependencies": { + "figures": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/figures/-/figures-1.7.0.tgz", + "integrity": "sha1-y+Hjr/zxzUS4DK3+0o3Hk6lwHS4=", + "dev": true, + "requires": { + "escape-string-regexp": "1.0.5", + "object-assign": "4.1.1" + } + }, + "log-symbols": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-1.0.2.tgz", + "integrity": "sha1-N2/3tY6jCGoPCfrMdGF+ylAeGhg=", "dev": true, "requires": { - "onetime": "2.0.1", - "signal-exit": "3.0.2" + "chalk": "1.1.3" } - }, - "run-async": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz", - "integrity": "sha1-A3GrSuC91yDUFm19/aZP96RFpsA=", + } + } + }, + "listr-silent-renderer": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/listr-silent-renderer/-/listr-silent-renderer-1.1.1.tgz", + "integrity": "sha1-kktaN1cVN3C/Go4/v3S4u/P5JC4=", + "dev": true + }, + "listr-update-renderer": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/listr-update-renderer/-/listr-update-renderer-0.2.0.tgz", + "integrity": "sha1-yoDhd5tOcCZoB+ju0a1qvjmFUPk=", + "dev": true, + "requires": { + "chalk": "1.1.3", + "cli-truncate": "0.2.1", + "elegant-spinner": "1.0.1", + "figures": "1.7.0", + "indent-string": "3.2.0", + "log-symbols": "1.0.2", + "log-update": "1.0.2", + "strip-ansi": "3.0.1" + }, + "dependencies": { + "figures": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/figures/-/figures-1.7.0.tgz", + "integrity": "sha1-y+Hjr/zxzUS4DK3+0o3Hk6lwHS4=", "dev": true, "requires": { - "is-promise": "2.1.0" + "escape-string-regexp": "1.0.5", + "object-assign": "4.1.1" } }, - "rx-lite": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-4.0.8.tgz", - "integrity": "sha1-Cx4Rr4vESDbwSmQH6S2kJGe3lEQ=", + "indent-string": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-3.2.0.tgz", + "integrity": "sha1-Sl/W0nzDMvN+VBmlBNu4NxBckok=", "dev": true }, - "string-width": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "log-symbols": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-1.0.2.tgz", + "integrity": "sha1-N2/3tY6jCGoPCfrMdGF+ylAeGhg=", + "dev": true, + "requires": { + "chalk": "1.1.3" + } + } + } + }, + "listr-verbose-renderer": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/listr-verbose-renderer/-/listr-verbose-renderer-0.4.1.tgz", + "integrity": "sha1-ggb0z21S3cWCfl/RSYng6WWTOjU=", + "dev": true, + "requires": { + "chalk": "1.1.3", + "cli-cursor": "1.0.2", + "date-fns": "1.29.0", + "figures": "1.7.0" + }, + "dependencies": { + "cli-cursor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-1.0.2.tgz", + "integrity": "sha1-ZNo/fValRBLll5S9Ytw1KV6PKYc=", "dev": true, "requires": { - "is-fullwidth-code-point": "2.0.0", - "strip-ansi": "4.0.0" + "restore-cursor": "1.0.1" } }, - "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "figures": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/figures/-/figures-1.7.0.tgz", + "integrity": "sha1-y+Hjr/zxzUS4DK3+0o3Hk6lwHS4=", "dev": true, "requires": { - "ansi-regex": "3.0.0" + "escape-string-regexp": "1.0.5", + "object-assign": "4.1.1" } }, - "strip-bom": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", - "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", + "onetime": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz", + "integrity": "sha1-ofeDj4MUxRbwXs78vEzP4EtO14k=", "dev": true }, - "supports-color": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.4.0.tgz", - "integrity": "sha512-rKC3+DyXWgK0ZLKwmRsrkyHVZAjNkfzeehuFWdGGcqGDTZFH73+RH6S/RDAAxl9GusSjZSUWYLmT9N5pzXFOXQ==", + "restore-cursor": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-1.0.1.tgz", + "integrity": "sha1-NGYfRohjJ/7SmRR5FSJS35LapUE=", "dev": true, "requires": { - "has-flag": "2.0.0" + "exit-hook": "1.1.1", + "onetime": "1.1.0" } } } }, - "levn": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", - "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", - "dev": true, - "requires": { - "prelude-ls": "1.1.2", - "type-check": "0.3.2" - } - }, - "lexical-scope": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/lexical-scope/-/lexical-scope-1.2.0.tgz", - "integrity": "sha1-/Ope3HBKSzqHls3KQZw6CvryLfQ=", - "dev": true, - "requires": { - "astw": "2.2.0" - } - }, - "liftoff": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/liftoff/-/liftoff-2.3.0.tgz", - "integrity": "sha1-qY8v9nGD2Lp8+soQVIvX/wVQs4U=", - "dev": true, - "requires": { - "extend": "3.0.1", - "findup-sync": "0.4.3", - "fined": "1.1.0", - "flagged-respawn": "0.3.2", - "lodash.isplainobject": "4.0.6", - "lodash.isstring": "4.0.1", - "lodash.mapvalues": "4.6.0", - "rechoir": "0.6.2", - "resolve": "1.4.0" - } - }, "load-json-file": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", @@ -12890,6 +14660,12 @@ "integrity": "sha1-LcvSwofLwKVcxCMovQxzYVDVPj8=", "dev": true }, + "lodash.merge": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.0.tgz", + "integrity": "sha1-aYhLoUSsM/5plzemCG3v+t0PicU=", + "dev": true + }, "lodash.restparam": { "version": "3.6.1", "resolved": "https://registry.npmjs.org/lodash.restparam/-/lodash.restparam-3.6.1.tgz", @@ -12923,6 +14699,95 @@ "lodash.escape": "3.2.0" } }, + "lodash.unescape": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/lodash.unescape/-/lodash.unescape-4.0.1.tgz", + "integrity": "sha1-vyJJiGzlFM2hEvrpIYzcBlIR/Jw=", + "dev": true + }, + "log-symbols": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-2.1.0.tgz", + "integrity": "sha512-zLeLrzMA1A2vRF1e/0Mo+LNINzi6jzBylHj5WqvQ/WK/5WCZt8si9SyN4p9llr/HRYvVR1AoXHRHl4WTHyQAzQ==", + "dev": true, + "requires": { + "chalk": "2.3.0" + }, + "dependencies": { + "ansi-styles": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", + "integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==", + "dev": true, + "requires": { + "color-convert": "1.9.1" + } + }, + "chalk": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz", + "integrity": "sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q==", + "dev": true, + "requires": { + "ansi-styles": "3.2.0", + "escape-string-regexp": "1.0.5", + "supports-color": "4.5.0" + } + }, + "supports-color": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz", + "integrity": "sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=", + "dev": true, + "requires": { + "has-flag": "2.0.0" + } + } + } + }, + "log-update": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/log-update/-/log-update-1.0.2.tgz", + "integrity": "sha1-GZKfZMQJPS0ucHWh2tivWcKWuNE=", + "dev": true, + "requires": { + "ansi-escapes": "1.4.0", + "cli-cursor": "1.0.2" + }, + "dependencies": { + "ansi-escapes": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-1.4.0.tgz", + "integrity": "sha1-06ioOzGapneTZisT52HHkRQiMG4=", + "dev": true + }, + "cli-cursor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-1.0.2.tgz", + "integrity": "sha1-ZNo/fValRBLll5S9Ytw1KV6PKYc=", + "dev": true, + "requires": { + "restore-cursor": "1.0.1" + } + }, + "onetime": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz", + "integrity": "sha1-ofeDj4MUxRbwXs78vEzP4EtO14k=", + "dev": true + }, + "restore-cursor": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-1.0.1.tgz", + "integrity": "sha1-NGYfRohjJ/7SmRR5FSJS35LapUE=", + "dev": true, + "requires": { + "exit-hook": "1.1.1", + "onetime": "1.1.0" + } + } + } + }, "log4js": { "version": "0.6.38", "resolved": "https://registry.npmjs.org/log4js/-/log4js-0.6.38.tgz", @@ -12959,12 +14824,34 @@ } } }, + "loglevel": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/loglevel/-/loglevel-1.5.1.tgz", + "integrity": "sha1-GJB4yUq5BT7iFaCs2/JCROoPZQI=", + "dev": true + }, + "loglevel-colored-level-prefix": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/loglevel-colored-level-prefix/-/loglevel-colored-level-prefix-1.0.0.tgz", + "integrity": "sha1-akAhj9x64V/HbD0PPmdsRlOIYD4=", + "dev": true, + "requires": { + "chalk": "1.1.3", + "loglevel": "1.5.1" + } + }, "lolex": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/lolex/-/lolex-1.3.2.tgz", "integrity": "sha1-fD2mL/yzDw9agKJWbKJORdigHzE=", "dev": true }, + "longest": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz", + "integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc=", + "dev": true + }, "loose-envify": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.3.1.tgz", @@ -12984,19 +14871,55 @@ "signal-exit": "3.0.2" } }, - "lru-cache": { - "version": "2.7.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.7.3.tgz", - "integrity": "sha1-bUUk6LlV+V1PW1iFHOId1y+06VI=", + "lowercase-keys": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.0.tgz", + "integrity": "sha1-TjNms55/VFfjXxMkvfb4jQv8cwY=", "dev": true }, + "lru-cache": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.1.tgz", + "integrity": "sha512-q4spe4KTfsAS1SUHLO0wz8Qiyf1+vMIAgpRYioFYDMNqKfHQbg+AVDH3i4fvpl71/P1L0dBl+fQi+P37UYf0ew==", + "dev": true, + "requires": { + "pseudomap": "1.0.2", + "yallist": "2.1.2" + } + }, "make-dir": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-1.0.0.tgz", - "integrity": "sha1-l6ARdR6R3YfPre9Ygy67BJNt6Xg=", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-1.1.0.tgz", + "integrity": "sha512-0Pkui4wLJ7rxvmfUvs87skoEaxmu0hCUApF8nonzpl7q//FWp9zu8W61Scz4sd/kUiqDxvUhtoam2efDyiBzcA==", "dev": true, "requires": { - "pify": "2.3.0" + "pify": "3.0.0" + }, + "dependencies": { + "pify": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", + "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", + "dev": true + } + } + }, + "make-plural": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/make-plural/-/make-plural-3.0.6.tgz", + "integrity": "sha1-IDOgO6wpC487uRJY9lud9+iwHKc=", + "dev": true, + "requires": { + "minimist": "1.2.0" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "dev": true, + "optional": true + } } }, "map-cache": { @@ -13074,25 +14997,60 @@ } } }, - "merge": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/merge/-/merge-1.2.0.tgz", - "integrity": "sha1-dTHjnUlJwoGma4xabgJl6LBYlNo=", + "merge": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/merge/-/merge-1.2.0.tgz", + "integrity": "sha1-dTHjnUlJwoGma4xabgJl6LBYlNo=", + "dev": true + }, + "merge-stream": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-1.0.1.tgz", + "integrity": "sha1-QEEgLVCKNCugAXQAjfDCUbjBNeE=", + "dev": true, + "requires": { + "readable-stream": "2.3.3" + } + }, + "messageformat": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/messageformat/-/messageformat-1.0.2.tgz", + "integrity": "sha1-kI9GkfKf8o2uNcRUNqJM/5NAI4g=", + "dev": true, + "requires": { + "glob": "7.0.6", + "make-plural": "3.0.6", + "messageformat-parser": "1.1.0", + "nopt": "3.0.6", + "reserved-words": "0.1.2" + }, + "dependencies": { + "glob": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.0.6.tgz", + "integrity": "sha1-IRuvr0nlJbjNkyYNFKsTYVKz9Xo=", + "dev": true, + "requires": { + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" + } + } + } + }, + "messageformat-parser": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/messageformat-parser/-/messageformat-parser-1.1.0.tgz", + "integrity": "sha512-Hwem6G3MsKDLS1FtBRGIs8T50P1Q00r3srS6QJePCFbad9fq0nYxwf3rnU2BreApRGhmpKMV7oZI06Sy1c9TPA==", "dev": true }, - "merge-stream": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-1.0.1.tgz", - "integrity": "sha1-QEEgLVCKNCugAXQAjfDCUbjBNeE=", - "dev": true, - "requires": { - "readable-stream": "2.3.3" - } - }, "metal": { - "version": "2.13.2", - "resolved": "https://registry.npmjs.org/metal/-/metal-2.13.2.tgz", - "integrity": "sha512-DqETxwvyW5I/3blSlxrr1eleLaLHItK1VJcGIL6hAVqSlUpYw0r+RXd8qWfIq6TMdjCU3/x/oGmWZyk+O4SZJw==", + "version": "2.14.0", + "resolved": "https://registry.npmjs.org/metal/-/metal-2.14.0.tgz", + "integrity": "sha512-dk4MUJZ5Rj+sB9RgZcATU8QRDxHKPn85ymVWC+PamDhcIEYsY5Fg+I6vOQ1Bo4J+54z/k9KF2K7fmUIRtoRb+w==", "dev": true }, "metal-tools-soy": { @@ -13235,7 +15193,7 @@ "integrity": "sha1-XIgDbPVl5d8FVYv8kR+GVt8hiIQ=", "dev": true, "requires": { - "clone": "1.0.2", + "clone": "1.0.3", "clone-stats": "0.0.1", "replace-ext": "0.0.1" } @@ -13273,7 +15231,7 @@ "integrity": "sha1-9Yfb1hPE18kFBjn1iXMSdThjcWk=", "dev": true, "requires": { - "metal": "2.13.2" + "metal": "2.14.0" } }, "micromatch": { @@ -13419,6 +15377,12 @@ "minimatch": "0.3.0" } }, + "lru-cache": { + "version": "2.7.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.7.3.tgz", + "integrity": "sha1-bUUk6LlV+V1PW1iFHOId1y+06VI=", + "dev": true + }, "minimatch": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-0.3.0.tgz", @@ -13455,6 +15419,7 @@ "integrity": "sha1-IyFYM/HaE/1gbMuAh7RIUty4If0=", "dev": true, "requires": { + "JSONStream": "1.3.1", "browser-resolve": "1.11.2", "cached-path-relative": "1.0.1", "concat-stream": "1.5.2", @@ -13462,10 +15427,9 @@ "detective": "4.5.0", "duplexer2": "0.1.4", "inherits": "2.0.3", - "JSONStream": "1.3.1", "parents": "1.0.1", "readable-stream": "2.3.3", - "resolve": "1.4.0", + "resolve": "1.5.0", "stream-combiner2": "1.1.1", "subarg": "1.0.0", "through2": "2.0.3", @@ -13473,9 +15437,9 @@ } }, "moment": { - "version": "2.19.0", - "resolved": "https://registry.npmjs.org/moment/-/moment-2.19.0.tgz", - "integrity": "sha1-RPZ172uUSUJ2JYGxwXn7Z55ZnWc=", + "version": "2.19.1", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.19.1.tgz", + "integrity": "sha1-VtoaLRy/AdOLfhr8McELz6GSkWc=", "dev": true }, "mout": { @@ -13535,11 +15499,18 @@ } }, "mute-stream": { - "version": "0.0.5", - "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.5.tgz", - "integrity": "sha1-j7+rsKmKJT0xhDMfno3rc3L6xsA=", + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", + "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=", "dev": true }, + "nan": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.7.0.tgz", + "integrity": "sha1-2Vv3IeyHfgjbJ27T/G63j5CDrUY=", + "dev": true, + "optional": true + }, "natives": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/natives/-/natives-1.1.0.tgz", @@ -13558,6 +15529,16 @@ "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=", "dev": true }, + "node-fetch": { + "version": "1.7.3", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz", + "integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==", + "dev": true, + "requires": { + "encoding": "0.1.12", + "is-stream": "1.1.0" + } + }, "nopt": { "version": "3.0.6", "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", @@ -13594,6 +15575,15 @@ "integrity": "sha1-LRDAa9/TEuqXd2laTShDlFa3WUI=", "dev": true }, + "npm-path": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/npm-path/-/npm-path-2.0.3.tgz", + "integrity": "sha1-Fc/04ciaONp39W9gVbJPl137K74=", + "dev": true, + "requires": { + "which": "1.3.0" + } + }, "npm-run-path": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", @@ -13603,6 +15593,17 @@ "path-key": "2.0.1" } }, + "npm-which": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/npm-which/-/npm-which-3.0.1.tgz", + "integrity": "sha1-kiXybsOihcIJyuZ8OxGmtKtxQKo=", + "dev": true, + "requires": { + "commander": "2.11.0", + "npm-path": "2.0.3", + "which": "1.3.0" + } + }, "npmlog": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz", @@ -13634,9 +15635,9 @@ "dev": true }, "nwmatcher": { - "version": "1.4.2", - "resolved": "https://registry.npmjs.org/nwmatcher/-/nwmatcher-1.4.2.tgz", - "integrity": "sha512-QMkCGQFYp5p+zwU3INntLmz1HMfSx9dMVJMYKmE1yuSf/22Wjo6VPFa405mCLUuQn9lbQvH2DZN9lt10ZNvtAg==", + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/nwmatcher/-/nwmatcher-1.4.3.tgz", + "integrity": "sha512-IKdSTiDWCarf2JTS5e9e2+5tPZGdkRJ79XjYV0pzK8Q9BpsFyBq1RGKxzs7Q8UBushGw7m6TzVKz6fcY99iSWw==", "dev": true }, "oauth-sign": { @@ -13663,17 +15664,6 @@ "integrity": "sha1-xUYBd4rVYPEULODgG8yotW0TQm0=", "dev": true }, - "object.assign": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.0.4.tgz", - "integrity": "sha1-scnMBE7xuf5jYG/BQau7MuFHMMw=", - "dev": true, - "requires": { - "define-properties": "1.1.2", - "function-bind": "1.1.1", - "object-keys": "1.0.11" - } - }, "object.defaults": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/object.defaults/-/object.defaults-1.1.0.tgz", @@ -13749,10 +15739,13 @@ } }, "onetime": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz", - "integrity": "sha1-ofeDj4MUxRbwXs78vEzP4EtO14k=", - "dev": true + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz", + "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=", + "dev": true, + "requires": { + "mimic-fn": "1.1.0" + } }, "optimist": { "version": "0.6.1", @@ -13792,6 +15785,45 @@ "integrity": "sha1-7CLTEoBrtT5zF3Pnza788cZDEo8=", "dev": true }, + "ora": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/ora/-/ora-0.2.3.tgz", + "integrity": "sha1-N1J9Igrc1Tw5tzVx11QVbV22V6Q=", + "dev": true, + "requires": { + "chalk": "1.1.3", + "cli-cursor": "1.0.2", + "cli-spinners": "0.1.2", + "object-assign": "4.1.1" + }, + "dependencies": { + "cli-cursor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-1.0.2.tgz", + "integrity": "sha1-ZNo/fValRBLll5S9Ytw1KV6PKYc=", + "dev": true, + "requires": { + "restore-cursor": "1.0.1" + } + }, + "onetime": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz", + "integrity": "sha1-ofeDj4MUxRbwXs78vEzP4EtO14k=", + "dev": true + }, + "restore-cursor": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-1.0.1.tgz", + "integrity": "sha1-NGYfRohjJ/7SmRR5FSJS35LapUE=", + "dev": true, + "requires": { + "exit-hook": "1.1.1", + "onetime": "1.1.0" + } + } + } + }, "orchestrator": { "version": "0.3.8", "resolved": "https://registry.npmjs.org/orchestrator/-/orchestrator-0.3.8.tgz", @@ -13891,6 +15923,24 @@ "p-limit": "1.1.0" } }, + "p-map": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/p-map/-/p-map-1.2.0.tgz", + "integrity": "sha512-r6zKACMNhjPJMTl8KcFH4li//gkrXWfbD6feV8l6doRHlzljFWGJ2AP6iKaCJXyZmAUMOPtvbW7EXkbWO/pLEA==", + "dev": true + }, + "package-json": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/package-json/-/package-json-4.0.1.tgz", + "integrity": "sha1-iGmgQBJTZhxMTKPabCEh7VVfXu0=", + "dev": true, + "requires": { + "got": "6.7.1", + "registry-auth-token": "3.3.1", + "registry-url": "3.1.0", + "semver": "5.4.1" + } + }, "pako": { "version": "0.2.9", "resolved": "https://registry.npmjs.org/pako/-/pako-0.2.9.tgz", @@ -13912,8 +15962,8 @@ "integrity": "sha1-N8T5t+06tlx0gXtfJICTf7+XxxI=", "dev": true, "requires": { - "asn1.js": "4.9.1", - "browserify-aes": "1.0.8", + "asn1.js": "4.9.2", + "browserify-aes": "1.1.1", "create-hash": "1.1.3", "evp_bytestokey": "1.0.3", "pbkdf2": "3.0.14" @@ -14120,9 +16170,9 @@ } }, "pluralize": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-1.2.1.tgz", - "integrity": "sha1-0aIUg/0iu0HlihL6NCGCMUCJfEU=", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-7.0.0.tgz", + "integrity": "sha512-ARhBOdzS3e41FbkW/XWrTEtukqqLoK5+Z/4UeDaLuSW+39JPeFgs4gCGqsrJHVZX0fUrx//4OF0K1CUGwlIFow==", "dev": true }, "posix-getopt": { @@ -14143,6 +16193,12 @@ "supports-color": "3.2.3" }, "dependencies": { + "has-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz", + "integrity": "sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo=", + "dev": true + }, "supports-color": { "version": "3.2.3", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.2.3.tgz", @@ -14166,12 +16222,179 @@ "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", "dev": true }, + "prepend-http": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-1.0.4.tgz", + "integrity": "sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw=", + "dev": true + }, "preserve": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/preserve/-/preserve-0.2.0.tgz", "integrity": "sha1-gV7R9uvGWSb4ZbMQwHE7yzMVzks=", "dev": true }, + "prettier": { + "version": "1.8.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.8.2.tgz", + "integrity": "sha512-fHWjCwoRZgjP1rvLP7OGqOznq7xH1sHMQUFLX8qLRO79hI57+6xbc5vB904LxEkCfgFgyr3vv06JkafgCSzoZg==", + "dev": true + }, + "prettier-eslint": { + "version": "8.2.1", + "resolved": "https://registry.npmjs.org/prettier-eslint/-/prettier-eslint-8.2.1.tgz", + "integrity": "sha512-z19e81masHigXh4Uz2rKL344amyeW56LWjmALnOGUZMiHDxWwYswbv2ZriA7aTKitSH909eN4+h4GqQDXeZOvA==", + "dev": true, + "requires": { + "common-tags": "1.4.0", + "dlv": "1.1.0", + "eslint": "4.10.0", + "indent-string": "3.2.0", + "lodash.merge": "4.6.0", + "loglevel-colored-level-prefix": "1.0.0", + "prettier": "1.8.2", + "pretty-format": "20.0.3", + "require-relative": "0.8.7", + "typescript": "2.6.1", + "typescript-eslint-parser": "8.0.1" + }, + "dependencies": { + "indent-string": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-3.2.0.tgz", + "integrity": "sha1-Sl/W0nzDMvN+VBmlBNu4NxBckok=", + "dev": true + } + } + }, + "prettier-eslint-cli": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/prettier-eslint-cli/-/prettier-eslint-cli-4.4.0.tgz", + "integrity": "sha512-q7kAFt+JpUQJALs110mpaT0+NEMZ4tt1SgOmeNL1D+13rABH0nIMw8fy3NnaTMSmRH9Wfuct6jHSDyqdb9PpVQ==", + "dev": true, + "requires": { + "arrify": "1.0.1", + "babel-runtime": "6.26.0", + "boolify": "1.0.1", + "camelcase-keys": "4.1.0", + "chalk": "2.1.0", + "common-tags": "1.4.0", + "eslint": "4.10.0", + "find-up": "2.1.0", + "get-stdin": "5.0.1", + "glob": "7.1.2", + "ignore": "3.3.7", + "indent-string": "3.2.0", + "lodash.memoize": "4.1.2", + "loglevel-colored-level-prefix": "1.0.0", + "messageformat": "1.0.2", + "prettier-eslint": "8.2.1", + "rxjs": "5.5.2", + "yargs": "8.0.2" + }, + "dependencies": { + "ansi-styles": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", + "integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==", + "dev": true, + "requires": { + "color-convert": "1.9.1" + } + }, + "camelcase": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz", + "integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=", + "dev": true + }, + "camelcase-keys": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-4.1.0.tgz", + "integrity": "sha1-IU00jMVFfzkxaiwxzD43JGMl5z8=", + "dev": true, + "requires": { + "camelcase": "4.1.0", + "map-obj": "2.0.0", + "quick-lru": "1.1.0" + } + }, + "chalk": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.1.0.tgz", + "integrity": "sha512-LUHGS/dge4ujbXMJrnihYMcL4AoOweGnw9Tp3kQuqy1Kx5c1qKjqvMJZ6nVJPMWJtKCTN72ZogH3oeSO9g9rXQ==", + "dev": true, + "requires": { + "ansi-styles": "3.2.0", + "escape-string-regexp": "1.0.5", + "supports-color": "4.5.0" + } + }, + "find-up": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", + "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", + "dev": true, + "requires": { + "locate-path": "2.0.0" + } + }, + "get-stdin": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-5.0.1.tgz", + "integrity": "sha1-Ei4WFZHiH/TFJTAwVpPyDmOTo5g=", + "dev": true + }, + "indent-string": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-3.2.0.tgz", + "integrity": "sha1-Sl/W0nzDMvN+VBmlBNu4NxBckok=", + "dev": true + }, + "lodash.memoize": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", + "integrity": "sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4=", + "dev": true + }, + "map-obj": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-2.0.0.tgz", + "integrity": "sha1-plzSkIepJZi4eRJXpSPgISIqwfk=", + "dev": true + }, + "supports-color": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz", + "integrity": "sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=", + "dev": true, + "requires": { + "has-flag": "2.0.0" + } + } + } + }, + "pretty-format": { + "version": "20.0.3", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-20.0.3.tgz", + "integrity": "sha1-Ag41ClYKH+GpjcO+tsz/s4beixQ=", + "dev": true, + "requires": { + "ansi-regex": "2.1.1", + "ansi-styles": "3.2.0" + }, + "dependencies": { + "ansi-styles": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", + "integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==", + "dev": true, + "requires": { + "color-convert": "1.9.1" + } + } + } + }, "pretty-hrtime": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz", @@ -14179,9 +16402,9 @@ "dev": true }, "private": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/private/-/private-0.1.7.tgz", - "integrity": "sha1-aM5eih7woju1cMwoU3tTMqumPvE=", + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/private/-/private-0.1.8.tgz", + "integrity": "sha512-VvivMrbvd2nKkiG38qjULzlc+4Vx4wm/whI9pQD35YrARNnhxeiRktSOhSukRLFNlzg6Br/cJPet5J/u19r/mg==", "dev": true }, "process": { @@ -14197,11 +16420,31 @@ "dev": true }, "progress": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/progress/-/progress-1.1.8.tgz", - "integrity": "sha1-4mDHj2Fhzdmw5WzD4Khd4Xx6V74=", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.0.tgz", + "integrity": "sha1-ihvjZr+Pwj2yvSPxDG/pILQ4nR8=", "dev": true }, + "promise": { + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz", + "integrity": "sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg==", + "dev": true, + "requires": { + "asap": "2.0.6" + } + }, + "prop-types": { + "version": "15.6.0", + "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.6.0.tgz", + "integrity": "sha1-zq8IMCL8RrSjX2nhPvda7Q1jmFY=", + "dev": true, + "requires": { + "fbjs": "0.8.16", + "loose-envify": "1.3.1", + "object-assign": "4.1.1" + } + }, "pseudomap": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", @@ -14228,9 +16471,9 @@ "dev": true }, "q": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/q/-/q-1.5.0.tgz", - "integrity": "sha1-3QG6ydBtMObyGa7LglPunr3DCPE=", + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", + "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=", "dev": true }, "qjobs": { @@ -14257,6 +16500,12 @@ "integrity": "sha1-nsYfeQSYdXB9aUFFlv2Qek1xHnM=", "dev": true }, + "quick-lru": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-1.1.0.tgz", + "integrity": "sha1-Q2CxfGETatOAeDl/8RQW4Ybc+7g=", + "dev": true + }, "randomatic": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", @@ -14282,7 +16531,7 @@ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "1.1.5" + "is-buffer": "1.1.6" } } } @@ -14293,7 +16542,7 @@ "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", "dev": true, "requires": { - "is-buffer": "1.1.5" + "is-buffer": "1.1.6" } } } @@ -14307,6 +16556,16 @@ "safe-buffer": "5.1.1" } }, + "randomfill": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/randomfill/-/randomfill-1.0.3.tgz", + "integrity": "sha512-YL6GrhrWoic0Eq8rXVbMptH7dAxCs0J+mh5Y0euNekPPYaxEmdVGim6GdoxoRzKW2yJoU8tueifS7mYxvcFDEQ==", + "dev": true, + "requires": { + "randombytes": "2.0.5", + "safe-buffer": "5.1.1" + } + }, "range-parser": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz", @@ -14323,12 +16582,24 @@ "http-errors": "1.6.2", "iconv-lite": "0.4.19", "unpipe": "1.0.0" + } + }, + "rc": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.2.tgz", + "integrity": "sha1-2M6ctX6NZNnHut2YdsfDTL48cHc=", + "dev": true, + "requires": { + "deep-extend": "0.4.2", + "ini": "1.3.4", + "minimist": "1.2.0", + "strip-json-comments": "2.0.1" }, "dependencies": { - "iconv-lite": { - "version": "0.4.19", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz", - "integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ==", + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", "dev": true } } @@ -14419,6 +16690,23 @@ "code-point-at": "1.1.0", "is-fullwidth-code-point": "1.0.0", "mute-stream": "0.0.5" + }, + "dependencies": { + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "dev": true, + "requires": { + "number-is-nan": "1.0.1" + } + }, + "mute-stream": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.5.tgz", + "integrity": "sha1-j7+rsKmKJT0xhDMfno3rc3L6xsA=", + "dev": true + } } }, "rechoir": { @@ -14427,7 +16715,7 @@ "integrity": "sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=", "dev": true, "requires": { - "resolve": "1.4.0" + "resolve": "1.5.0" } }, "redent": { @@ -14460,7 +16748,7 @@ "requires": { "babel-runtime": "6.26.0", "babel-types": "6.26.0", - "private": "0.1.7" + "private": "0.1.8" } }, "regex-cache": { @@ -14483,6 +16771,25 @@ "regjsparser": "0.1.5" } }, + "registry-auth-token": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/registry-auth-token/-/registry-auth-token-3.3.1.tgz", + "integrity": "sha1-+w0yie4Nmtosu1KvXf5mywcNMAY=", + "dev": true, + "requires": { + "rc": "1.2.2", + "safe-buffer": "5.1.1" + } + }, + "registry-url": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/registry-url/-/registry-url-3.1.0.tgz", + "integrity": "sha1-PU74cPc93h138M+aOBQyRE4XSUI=", + "dev": true, + "requires": { + "rc": "1.2.2" + } + }, "regjsgen": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/regjsgen/-/regjsgen-0.2.0.tgz", @@ -14586,12 +16893,24 @@ "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", "dev": true }, + "require-from-string": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-1.2.1.tgz", + "integrity": "sha1-UpyczvJzgK3+yaL5ZbZJu+5jZBg=", + "dev": true + }, "require-main-filename": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-1.0.1.tgz", "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=", "dev": true }, + "require-relative": { + "version": "0.8.7", + "resolved": "https://registry.npmjs.org/require-relative/-/require-relative-0.8.7.tgz", + "integrity": "sha1-eZlTn8ngR6N5KPoZb44VY9q9Nt4=", + "dev": true + }, "require-uncached": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/require-uncached/-/require-uncached-1.0.3.tgz", @@ -14608,10 +16927,16 @@ "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=", "dev": true }, + "reserved-words": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/reserved-words/-/reserved-words-0.1.2.tgz", + "integrity": "sha1-AKCUD5jNUBrqqsMWQR2a3FKzGrE=", + "dev": true + }, "resolve": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.4.0.tgz", - "integrity": "sha512-aW7sVKPufyHqOmyyLzg/J+8606v5nevBgaliIlV7nUpVMsDnoBGV/cbSLNjZAg9q0Cfd/+easKVKQ8vOu8fn1Q==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.5.0.tgz", + "integrity": "sha512-hgoSGrc3pjzAPHNBg+KnFcK2HwlHTs/YrAGUr6qgTVUZmXv1UEXXl0bZNBKMA9fud6lRYFdPGz0xXxycPzmmiw==", "dev": true, "requires": { "path-parse": "1.0.5" @@ -14634,13 +16959,23 @@ "dev": true }, "restore-cursor": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-1.0.1.tgz", - "integrity": "sha1-NGYfRohjJ/7SmRR5FSJS35LapUE=", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", + "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=", + "dev": true, + "requires": { + "onetime": "2.0.1", + "signal-exit": "3.0.2" + } + }, + "right-align": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz", + "integrity": "sha1-YTObci/mo1FWiSENJOFMlhSGE+8=", "dev": true, + "optional": true, "requires": { - "exit-hook": "1.1.1", - "onetime": "1.1.0" + "align-text": "0.1.4" } }, "rimraf": { @@ -14663,18 +16998,18 @@ } }, "run-async": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/run-async/-/run-async-0.1.0.tgz", - "integrity": "sha1-yK1KXhEGYeQCp9IbUw4AnyX444k=", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz", + "integrity": "sha1-A3GrSuC91yDUFm19/aZP96RFpsA=", "dev": true, "requires": { - "once": "1.4.0" + "is-promise": "2.1.0" } }, "rx-lite": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-3.1.2.tgz", - "integrity": "sha1-Gc5QLKVyZl87ZHsQk5+X/RYV8QI=", + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-4.0.8.tgz", + "integrity": "sha1-Cx4Rr4vESDbwSmQH6S2kJGe3lEQ=", "dev": true }, "rx-lite-aggregates": { @@ -14683,7 +17018,16 @@ "integrity": "sha1-dTuHqJoRyVRnxKwWJsTvxOBcZ74=", "dev": true, "requires": { - "rx-lite": "3.1.2" + "rx-lite": "4.0.8" + } + }, + "rxjs": { + "version": "5.5.2", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-5.5.2.tgz", + "integrity": "sha512-oRYoIKWBU3Ic37fLA5VJu31VqQO4bWubRntcHSJ+cwaDQBwdnZ9x4zmhJfm/nFQ2E82/I4loSioHnACamrKGgA==", + "dev": true, + "requires": { + "symbol-observable": "1.0.4" } }, "safe-buffer": { @@ -14728,6 +17072,12 @@ "integrity": "sha1-SysbJ+uAip+NzEgaWOXlb1mfP2E=", "dev": true }, + "setimmediate": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", + "integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU=", + "dev": true + }, "setprototypeof": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.3.tgz", @@ -14823,15 +17173,18 @@ "dev": true }, "slice-ansi": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-0.0.4.tgz", - "integrity": "sha1-7b+JA/ZvfOL46v1s7tZeJkyDGzU=", - "dev": true + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-1.0.0.tgz", + "integrity": "sha512-POqxBK6Lb3q6s047D/XsDVNPnF9Dl8JSaqe9h9lURl0OdNqy/ujDrOiIHtsqXMGbWWTIomRzAMaTyawAU//Reg==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "2.0.0" + } }, "sntp": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.0.2.tgz", - "integrity": "sha1-UGQRDwr4X3z9t9a2ekACjOUrSys=", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", + "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", "dev": true, "requires": { "hoek": "4.2.0" @@ -15072,14 +17425,24 @@ "requires": { "asn1": "0.2.3", "assert-plus": "1.0.0", + "bcrypt-pbkdf": "1.0.1", "dashdash": "1.14.1", - "getpass": "0.1.7" + "ecc-jsbn": "0.1.1", + "getpass": "0.1.7", + "jsbn": "0.1.1", + "tweetnacl": "0.14.5" } }, + "staged-git-files": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/staged-git-files/-/staged-git-files-0.0.4.tgz", + "integrity": "sha1-15fhtVHKemOd7AI33G60u5vhfTU=", + "dev": true + }, "statuses": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz", - "integrity": "sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4=", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz", + "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew==", "dev": true }, "stream-browserify": { @@ -15147,21 +17510,54 @@ "readable-stream": "2.3.3" } }, + "stream-to-observable": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/stream-to-observable/-/stream-to-observable-0.1.0.tgz", + "integrity": "sha1-Rb8dny19wJvtgfHDB8Qw5ouEz/4=", + "dev": true + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "2.0.0", + "strip-ansi": "4.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "3.0.0" + } + } + } + }, "string_decoder": { "version": "0.10.31", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", "dev": true }, - "string-width": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", - "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "stringify-object": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/stringify-object/-/stringify-object-3.2.1.tgz", + "integrity": "sha512-jPcQYw/52HUPP8uOE4kkjxl5bB9LfHkKCTptIk3qw7ozP5XMIMlHMLjt00GGSwW6DJAf/njY5EU6Vpwl4LlBKQ==", "dev": true, "requires": { - "code-point-at": "1.1.0", - "is-fullwidth-code-point": "1.0.0", - "strip-ansi": "3.0.1" + "get-own-enumerable-property-symbols": "2.0.1", + "is-obj": "1.0.1", + "is-regexp": "1.0.0" } }, "stringstream": { @@ -15228,7 +17624,7 @@ "byline": "5.0.0", "duplexer": "0.1.1", "minimist": "0.1.0", - "moment": "2.19.0", + "moment": "2.19.1", "through": "2.3.8" }, "dependencies": { @@ -15263,6 +17659,12 @@ "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", "dev": true }, + "symbol-observable": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.0.4.tgz", + "integrity": "sha1-Kb9hXUqnEhvdiYsi1LP5vE4qoD0=", + "dev": true + }, "symbol-tree": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.2.tgz", @@ -15279,48 +17681,46 @@ } }, "table": { - "version": "3.8.3", - "resolved": "https://registry.npmjs.org/table/-/table-3.8.3.tgz", - "integrity": "sha1-K7xULw/amGGnVdOUf+/Ys/UThV8=", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/table/-/table-4.0.2.tgz", + "integrity": "sha512-UUkEAPdSGxtRpiV9ozJ5cMTtYiqz7Ni1OGqLXRCynrvzdtR1p+cfOWe2RJLwvUG8hNanaSRjecIqwOjqeatDsA==", "dev": true, "requires": { - "ajv": "4.11.8", - "ajv-keywords": "1.5.1", - "chalk": "1.1.3", + "ajv": "5.3.0", + "ajv-keywords": "2.1.1", + "chalk": "2.3.0", "lodash": "4.17.4", - "slice-ansi": "0.0.4", + "slice-ansi": "1.0.0", "string-width": "2.1.1" }, "dependencies": { - "ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", - "dev": true - }, - "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", - "dev": true + "ansi-styles": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", + "integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==", + "dev": true, + "requires": { + "color-convert": "1.9.1" + } }, - "string-width": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "chalk": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz", + "integrity": "sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q==", "dev": true, "requires": { - "is-fullwidth-code-point": "2.0.0", - "strip-ansi": "4.0.0" + "ansi-styles": "3.2.0", + "escape-string-regexp": "1.0.5", + "supports-color": "4.5.0" } }, - "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "supports-color": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz", + "integrity": "sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=", "dev": true, "requires": { - "ansi-regex": "3.0.0" + "has-flag": "2.0.0" } } } @@ -15339,7 +17739,7 @@ "requires": { "graceful-fs": "4.1.11", "is-stream": "1.1.0", - "make-dir": "1.0.0", + "make-dir": "1.1.0", "pify": "2.3.0", "temp-dir": "1.0.0", "uuid": "3.1.0" @@ -15447,6 +17847,12 @@ "integrity": "sha1-dkpaEa9QVhkhsTPztE5hhofg9cM=", "dev": true }, + "timed-out": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/timed-out/-/timed-out-4.0.1.tgz", + "integrity": "sha1-8y6srFoXW+ol1/q1Zas+2HQe9W8=", + "dev": true + }, "timers-browserify": { "version": "1.4.2", "resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-1.4.2.tgz", @@ -15457,9 +17863,9 @@ } }, "tmp": { - "version": "0.0.31", - "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.31.tgz", - "integrity": "sha1-jzirlDjhcxXl29izZX6L+yd65Kc=", + "version": "0.0.33", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", + "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", "dev": true, "requires": { "os-tmpdir": "1.0.2" @@ -15562,6 +17968,13 @@ "safe-buffer": "5.1.1" } }, + "tweetnacl": { + "version": "0.14.5", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", + "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", + "dev": true, + "optional": true + }, "type-check": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", @@ -15593,6 +18006,22 @@ "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", "dev": true }, + "typescript": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.6.1.tgz", + "integrity": "sha1-7znN6ierrAtQAkLWcmq5DgyEZjE=", + "dev": true + }, + "typescript-eslint-parser": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/typescript-eslint-parser/-/typescript-eslint-parser-8.0.1.tgz", + "integrity": "sha1-6MrFN9mW4Ww9uw18TVCXmeZ6/gw=", + "dev": true, + "requires": { + "lodash.unescape": "4.0.1", + "semver": "5.4.1" + } + }, "typhonjs-ast-walker": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/typhonjs-ast-walker/-/typhonjs-ast-walker-0.1.1.tgz", @@ -15648,6 +18077,72 @@ "integrity": "sha1-hN1eHQG0QRm95JPqZW3O+JJVq4Q=", "dev": true }, + "ua-parser-js": { + "version": "0.7.17", + "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.17.tgz", + "integrity": "sha512-uRdSdu1oA1rncCQL7sCj8vSyZkgtL7faaw9Tc9rZ3mGgraQ7+Pdx7w5mnOSF3gw9ZNG6oc+KXfkon3bKuROm0g==", + "dev": true + }, + "uglify-js": { + "version": "2.8.29", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.8.29.tgz", + "integrity": "sha1-KcVzMUgFe7Th913zW3qcty5qWd0=", + "dev": true, + "optional": true, + "requires": { + "source-map": "0.5.7", + "uglify-to-browserify": "1.0.2", + "yargs": "3.10.0" + }, + "dependencies": { + "camelcase": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz", + "integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=", + "dev": true, + "optional": true + }, + "cliui": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz", + "integrity": "sha1-S0dXYP+AJkx2LDoXGQMukcf+oNE=", + "dev": true, + "optional": true, + "requires": { + "center-align": "0.1.3", + "right-align": "0.1.3", + "wordwrap": "0.0.2" + } + }, + "wordwrap": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz", + "integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8=", + "dev": true, + "optional": true + }, + "yargs": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz", + "integrity": "sha1-9+572FfdfB0tOMDnTvvWgdFDH9E=", + "dev": true, + "optional": true, + "requires": { + "camelcase": "1.2.1", + "cliui": "2.1.0", + "decamelize": "1.2.0", + "window-size": "0.1.0" + } + } + } + }, + "uglify-to-browserify": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz", + "integrity": "sha1-bgkk1r2mta/jSeOabWMoUKD4grc=", + "dev": true, + "optional": true + }, "ultron": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/ultron/-/ultron-1.0.2.tgz", @@ -15684,6 +18179,12 @@ "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=", "dev": true }, + "unzip-response": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/unzip-response/-/unzip-response-2.0.1.tgz", + "integrity": "sha1-0vD3N9FrBhXnKmk17QQhRXLVb5c=", + "dev": true + }, "url": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/url/-/url-0.11.0.tgz", @@ -15702,6 +18203,15 @@ } } }, + "url-parse-lax": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/url-parse-lax/-/url-parse-lax-1.0.0.tgz", + "integrity": "sha1-evjzA2Rem9eaJy56FKxovAYJ2nM=", + "dev": true, + "requires": { + "prepend-http": "1.0.4" + } + }, "user-home": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/user-home/-/user-home-1.1.1.tgz", @@ -15715,7 +18225,7 @@ "dev": true, "requires": { "lru-cache": "2.2.4", - "tmp": "0.0.31" + "tmp": "0.0.33" }, "dependencies": { "lru-cache": { @@ -15803,7 +18313,7 @@ "integrity": "sha1-sEVbOPxeDPMNQyUTLkYZcMIJHN4=", "dev": true, "requires": { - "clone": "1.0.2", + "clone": "1.0.3", "clone-stats": "0.0.1", "replace-ext": "0.0.1" } @@ -15920,7 +18430,7 @@ "dev": true, "requires": { "anymatch": "1.3.2", - "browserify": "14.4.0", + "browserify": "14.5.0", "chokidar": "1.7.0", "defined": "1.0.0", "outpipe": "1.1.1", @@ -15929,21 +18439,22 @@ }, "dependencies": { "browserify": { - "version": "14.4.0", - "resolved": "https://registry.npmjs.org/browserify/-/browserify-14.4.0.tgz", - "integrity": "sha1-CJo0Y69Y0OSNjNQHCz90ZU1avKk=", + "version": "14.5.0", + "resolved": "https://registry.npmjs.org/browserify/-/browserify-14.5.0.tgz", + "integrity": "sha512-gKfOsNQv/toWz+60nSPfYzuwSEdzvV2WdxrVPUbPD/qui44rAkB3t3muNtmmGYHqrG56FGwX9SUEQmzNLAeS7g==", "dev": true, "requires": { + "JSONStream": "1.3.1", "assert": "1.4.1", "browser-pack": "6.0.2", "browser-resolve": "1.11.2", - "browserify-zlib": "0.1.4", + "browserify-zlib": "0.2.0", "buffer": "5.0.8", "cached-path-relative": "1.0.1", "concat-stream": "1.5.2", "console-browserify": "1.1.0", "constants-browserify": "1.0.0", - "crypto-browserify": "3.11.1", + "crypto-browserify": "3.12.0", "defined": "1.0.0", "deps-sort": "2.0.0", "domain-browser": "1.1.7", @@ -15955,10 +18466,9 @@ "https-browserify": "1.0.0", "inherits": "2.0.3", "insert-module-globals": "7.0.1", - "JSONStream": "1.3.1", "labeled-stream-splicer": "2.0.0", "module-deps": "4.1.1", - "os-browserify": "0.1.2", + "os-browserify": "0.3.0", "parents": "1.0.1", "path-browserify": "0.0.0", "process": "0.11.10", @@ -15966,7 +18476,7 @@ "querystring-es3": "0.2.1", "read-only-stream": "2.0.0", "readable-stream": "2.3.3", - "resolve": "1.4.0", + "resolve": "1.5.0", "shasum": "1.0.2", "shell-quote": "1.6.1", "stream-browserify": "2.0.1", @@ -15983,6 +18493,15 @@ "xtend": "4.0.1" } }, + "browserify-zlib": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.2.0.tgz", + "integrity": "sha512-Z942RysHXmJrhqk88FmKBVq/v5tqmSkDz7p54G/MGyjMnCFFnC79XWNbg+Vta8W6Wb2qtSZTSxIGkJrRpCFEiA==", + "dev": true, + "requires": { + "pako": "1.0.6" + } + }, "buffer": { "version": "5.0.8", "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.0.8.tgz", @@ -15999,6 +18518,18 @@ "integrity": "sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM=", "dev": true }, + "os-browserify": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/os-browserify/-/os-browserify-0.3.0.tgz", + "integrity": "sha1-hUNzx/XCMVkU/Jv8a9gjj92h7Cc=", + "dev": true + }, + "pako": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.6.tgz", + "integrity": "sha512-lQe48YPsMJAig+yngZ87Lus+NF+3mtu7DVOBu6b/gHO1YpKwIj5AWjZ/TOS7i46HD/UixzWb1zeWDZfGZ3iYcg==", + "dev": true + }, "string_decoder": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", @@ -16026,14 +18557,20 @@ "dev": true }, "whatwg-encoding": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-1.0.1.tgz", - "integrity": "sha1-PGxFGhmO567FWx7GHQkgxngBpfQ=", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-1.0.3.tgz", + "integrity": "sha512-jLBwwKUhi8WtBfsMQlL4bUUcT8sMkAtQinscJAe/M4KHCkHuUJAF6vuB0tueNIw4c8ziO6AkRmgY+jL3a0iiPw==", "dev": true, "requires": { - "iconv-lite": "0.4.13" + "iconv-lite": "0.4.19" } }, + "whatwg-fetch": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-2.0.3.tgz", + "integrity": "sha1-nITsLc9oGH/wC8ZOEnS0QhduHIQ=", + "dev": true + }, "whatwg-url": { "version": "4.8.0", "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-4.8.0.tgz", @@ -16074,8 +18611,37 @@ "dev": true, "requires": { "string-width": "1.0.2" + }, + "dependencies": { + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "dev": true, + "requires": { + "number-is-nan": "1.0.1" + } + }, + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "dev": true, + "requires": { + "code-point-at": "1.1.0", + "is-fullwidth-code-point": "1.0.0", + "strip-ansi": "3.0.1" + } + } } }, + "window-size": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz", + "integrity": "sha1-VDjNLqk7IC76Ohn+iIeu58lPnJ0=", + "dev": true, + "optional": true + }, "wordwrap": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", @@ -16090,6 +18656,28 @@ "requires": { "string-width": "1.0.2", "strip-ansi": "3.0.1" + }, + "dependencies": { + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "dev": true, + "requires": { + "number-is-nan": "1.0.1" + } + }, + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "dev": true, + "requires": { + "code-point-at": "1.1.0", + "is-fullwidth-code-point": "1.0.0", + "strip-ansi": "3.0.1" + } + } } }, "wrappy": { @@ -16126,7 +18714,7 @@ "requires": { "detect-indent": "5.0.0", "graceful-fs": "4.1.11", - "make-dir": "1.0.0", + "make-dir": "1.1.0", "pify": "3.0.0", "sort-keys": "2.0.0", "write-file-atomic": "2.3.0" @@ -16223,12 +18811,6 @@ "yargs-parser": "7.0.0" }, "dependencies": { - "ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", - "dev": true - }, "camelcase": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz", @@ -16244,12 +18826,6 @@ "locate-path": "2.0.0" } }, - "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", - "dev": true - }, "load-json-file": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", @@ -16292,25 +18868,6 @@ "read-pkg": "2.0.0" } }, - "string-width": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", - "dev": true, - "requires": { - "is-fullwidth-code-point": "2.0.0", - "strip-ansi": "4.0.0" - } - }, - "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", - "dev": true, - "requires": { - "ansi-regex": "3.0.0" - } - }, "strip-bom": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", diff --git a/package.json b/package.json index 37a34252..1266d630 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,13 @@ { "private": true, "scripts": { + "checkFormat": "npm run prettier -- --list-different", "compile": "gulp build:cjs", - "format": "gulp format", + "format": "npm run prettier -- --write", "lerna": "lerna bootstrap -- --no-optional && npm install --no-optional", - "lint": "gulp lint", + "lint": "eslint 'packages/metal*/{src,test}/**/*.js'", + "precommit": "lint-staged", + "prettier": "prettier-eslint 'packages/metal*/{src,test}/**/*.js'", "test": "gulp test && npm run test:isomorphic", "test:coverage": "gulp test:coverage", "test:coverage:open": "gulp test:coverage:open", @@ -19,11 +22,14 @@ "babelify": "^7.3.0", "browserify": "^13.0.1", "chai": "^3.5.0", - "eslint-plugin-react": "^6.8.0", + "eslint": "^4.10.0", + "eslint-config-liferay": "^2.0.9", + "eslint-plugin-react": "^7.4.0", "gulp": "^3.8.11", "gulp-babel": "^6.1.2", "gulp-metal": "^1.0.0", "gulp-replace": "^0.5.4", + "husky": "^0.14.3", "jsdom": "^9.9.1", "jsdom-global": "^2.1.1", "karma": "^1.1.0", @@ -35,12 +41,20 @@ "karma-sinon": "^1.0.5", "karma-source-map-support": "^1.1.0", "lerna": "^2.2.0", + "lint-staged": "^4.3.0", "metal-tools-soy": "^2.4.0", "metal-useragent": "^2.1.2", "mocha": "^2.5.3", + "prettier-eslint-cli": "^4.4.0", "sinon": "^1.17.4", "watchify": "^3.7.0" }, + "lint-staged": { + "*.js": [ + "prettier-eslint --write", + "git add" + ] + }, "nyc": { "exclude": [ "packages/metal-incremental-dom/src/incremental-dom.js", diff --git a/packages/metal-assertions/package-lock.json b/packages/metal-assertions/package-lock.json index f9c637f5..7e4c66d6 100644 --- a/packages/metal-assertions/package-lock.json +++ b/packages/metal-assertions/package-lock.json @@ -64,7 +64,7 @@ "lodash": "4.17.4", "minimatch": "3.0.4", "path-is-absolute": "1.0.1", - "private": "0.1.7", + "private": "0.1.8", "slash": "1.0.0", "source-map": "0.5.7" } @@ -507,9 +507,9 @@ } }, "babel-preset-env": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/babel-preset-env/-/babel-preset-env-1.6.0.tgz", - "integrity": "sha512-OVgtQRuOZKckrILgMA5rvctvFZPv72Gua9Rt006AiPoB0DJKGN07UmaQA+qRrYgK71MVct8fFhT0EyNWYorVew==", + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/babel-preset-env/-/babel-preset-env-1.6.1.tgz", + "integrity": "sha512-W6VIyA6Ch9ePMI7VptNn2wBM6dbG0eSz25HEiL40nQXCsXGTGZSTZu1Iap+cj3Q0S5a7T9+529l/5Bkvd+afNA==", "requires": { "babel-plugin-check-es2015-constants": "6.22.0", "babel-plugin-syntax-trailing-function-commas": "6.22.0", @@ -538,7 +538,7 @@ "babel-plugin-transform-es2015-unicode-regex": "6.24.1", "babel-plugin-transform-exponentiation-operator": "6.24.1", "babel-plugin-transform-regenerator": "6.26.0", - "browserslist": "2.5.1", + "browserslist": "2.8.0", "invariant": "2.2.2", "semver": "5.4.1" } @@ -625,18 +625,18 @@ } }, "browserslist": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-2.5.1.tgz", - "integrity": "sha512-jAvM2ku7YDJ+leAq3bFH1DE0Ylw+F+EQDq4GkqZfgPEqpWYw9ofQH85uKSB9r3Tv7XDbfqVtE+sdvKJW7IlPJA==", + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-2.8.0.tgz", + "integrity": "sha512-iiWHM1Et6Q4TQpB7Ar6pxuM3TNMXasVJY4Y/oh3q38EwR3Z+IdZ9MyVf7PI4MJFB4xpwMcZgs9bEUnPG2E3TCA==", "requires": { - "caniuse-lite": "1.0.30000746", - "electron-to-chromium": "1.3.25" + "caniuse-lite": "1.0.30000760", + "electron-to-chromium": "1.3.27" } }, "caniuse-lite": { - "version": "1.0.30000746", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000746.tgz", - "integrity": "sha1-xk+Vo5Jc/TAgejCO12wa6W6gnqA=" + "version": "1.0.30000760", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000760.tgz", + "integrity": "sha1-7HIDlXQvHH7IlH/W3SYE53qPmP8=" }, "chalk": { "version": "1.1.3", @@ -687,9 +687,9 @@ } }, "electron-to-chromium": { - "version": "1.3.25", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.25.tgz", - "integrity": "sha1-RTshAJg20Jl9hgNWAf9srkeRxGA=" + "version": "1.3.27", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.27.tgz", + "integrity": "sha1-eOy4o5kGYYe7N07t412ccFZagD0=" }, "escape-string-regexp": { "version": "1.0.5", @@ -879,9 +879,9 @@ "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" }, "private": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/private/-/private-0.1.7.tgz", - "integrity": "sha1-aM5eih7woju1cMwoU3tTMqumPvE=" + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/private/-/private-0.1.8.tgz", + "integrity": "sha512-VvivMrbvd2nKkiG38qjULzlc+4Vx4wm/whI9pQD35YrARNnhxeiRktSOhSukRLFNlzg6Br/cJPet5J/u19r/mg==" }, "regenerate": { "version": "1.3.3", @@ -900,7 +900,7 @@ "requires": { "babel-runtime": "6.26.0", "babel-types": "6.26.0", - "private": "0.1.7" + "private": "0.1.8" } }, "regexpu-core": { diff --git a/packages/metal-dom/test/.eslintrc.json b/packages/metal-assertions/test/.eslintrc similarity index 60% rename from packages/metal-dom/test/.eslintrc.json rename to packages/metal-assertions/test/.eslintrc index 92b466f1..902156c0 100644 --- a/packages/metal-dom/test/.eslintrc.json +++ b/packages/metal-assertions/test/.eslintrc @@ -5,5 +5,9 @@ "globals": { "assert": true, "sinon": true + }, + "rules": { + "max-len": 0, + "require-jsdoc": 0 } -} +} \ No newline at end of file diff --git a/packages/metal-assertions/test/assertions.js b/packages/metal-assertions/test/assertions.js index e215c059..6bda9e24 100644 --- a/packages/metal-assertions/test/assertions.js +++ b/packages/metal-assertions/test/assertions.js @@ -189,5 +189,4 @@ describe('assertions', () => { }); }); }); - }); diff --git a/packages/metal-component/.eslintrc.json b/packages/metal-component/.eslintrc similarity index 100% rename from packages/metal-component/.eslintrc.json rename to packages/metal-component/.eslintrc diff --git a/packages/metal-component/package-lock.json b/packages/metal-component/package-lock.json index f9c637f5..7e4c66d6 100644 --- a/packages/metal-component/package-lock.json +++ b/packages/metal-component/package-lock.json @@ -64,7 +64,7 @@ "lodash": "4.17.4", "minimatch": "3.0.4", "path-is-absolute": "1.0.1", - "private": "0.1.7", + "private": "0.1.8", "slash": "1.0.0", "source-map": "0.5.7" } @@ -507,9 +507,9 @@ } }, "babel-preset-env": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/babel-preset-env/-/babel-preset-env-1.6.0.tgz", - "integrity": "sha512-OVgtQRuOZKckrILgMA5rvctvFZPv72Gua9Rt006AiPoB0DJKGN07UmaQA+qRrYgK71MVct8fFhT0EyNWYorVew==", + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/babel-preset-env/-/babel-preset-env-1.6.1.tgz", + "integrity": "sha512-W6VIyA6Ch9ePMI7VptNn2wBM6dbG0eSz25HEiL40nQXCsXGTGZSTZu1Iap+cj3Q0S5a7T9+529l/5Bkvd+afNA==", "requires": { "babel-plugin-check-es2015-constants": "6.22.0", "babel-plugin-syntax-trailing-function-commas": "6.22.0", @@ -538,7 +538,7 @@ "babel-plugin-transform-es2015-unicode-regex": "6.24.1", "babel-plugin-transform-exponentiation-operator": "6.24.1", "babel-plugin-transform-regenerator": "6.26.0", - "browserslist": "2.5.1", + "browserslist": "2.8.0", "invariant": "2.2.2", "semver": "5.4.1" } @@ -625,18 +625,18 @@ } }, "browserslist": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-2.5.1.tgz", - "integrity": "sha512-jAvM2ku7YDJ+leAq3bFH1DE0Ylw+F+EQDq4GkqZfgPEqpWYw9ofQH85uKSB9r3Tv7XDbfqVtE+sdvKJW7IlPJA==", + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-2.8.0.tgz", + "integrity": "sha512-iiWHM1Et6Q4TQpB7Ar6pxuM3TNMXasVJY4Y/oh3q38EwR3Z+IdZ9MyVf7PI4MJFB4xpwMcZgs9bEUnPG2E3TCA==", "requires": { - "caniuse-lite": "1.0.30000746", - "electron-to-chromium": "1.3.25" + "caniuse-lite": "1.0.30000760", + "electron-to-chromium": "1.3.27" } }, "caniuse-lite": { - "version": "1.0.30000746", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000746.tgz", - "integrity": "sha1-xk+Vo5Jc/TAgejCO12wa6W6gnqA=" + "version": "1.0.30000760", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000760.tgz", + "integrity": "sha1-7HIDlXQvHH7IlH/W3SYE53qPmP8=" }, "chalk": { "version": "1.1.3", @@ -687,9 +687,9 @@ } }, "electron-to-chromium": { - "version": "1.3.25", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.25.tgz", - "integrity": "sha1-RTshAJg20Jl9hgNWAf9srkeRxGA=" + "version": "1.3.27", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.27.tgz", + "integrity": "sha1-eOy4o5kGYYe7N07t412ccFZagD0=" }, "escape-string-regexp": { "version": "1.0.5", @@ -879,9 +879,9 @@ "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" }, "private": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/private/-/private-0.1.7.tgz", - "integrity": "sha1-aM5eih7woju1cMwoU3tTMqumPvE=" + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/private/-/private-0.1.8.tgz", + "integrity": "sha512-VvivMrbvd2nKkiG38qjULzlc+4Vx4wm/whI9pQD35YrARNnhxeiRktSOhSukRLFNlzg6Br/cJPet5J/u19r/mg==" }, "regenerate": { "version": "1.3.3", @@ -900,7 +900,7 @@ "requires": { "babel-runtime": "6.26.0", "babel-types": "6.26.0", - "private": "0.1.7" + "private": "0.1.8" } }, "regexpu-core": { diff --git a/packages/metal-component/src/Component.js b/packages/metal-component/src/Component.js index 9cc89901..519178f8 100644 --- a/packages/metal-component/src/Component.js +++ b/packages/metal-component/src/Component.js @@ -1,12 +1,21 @@ 'use strict'; -import { addListenersFromObj } from './events/events'; -import { getStaticProperty, isBoolean, isDefAndNotNull, isElement, isObject, isServerSide, isString, object } from 'metal'; -import { syncState } from './sync/sync'; -import { DomEventEmitterProxy, toElement } from 'metal-dom'; +import {addListenersFromObj} from './events/events'; +import { + getStaticProperty, + isBoolean, + isDefAndNotNull, + isElement, + isObject, + isServerSide, + isString, + object, +} from 'metal'; +import {syncState} from './sync/sync'; +import {DomEventEmitterProxy, toElement} from 'metal-dom'; import ComponentDataManager from './ComponentDataManager'; import ComponentRenderer from './ComponentRenderer'; -import { EventEmitter, EventHandler } from 'metal-events'; +import {EventEmitter, EventHandler} from 'metal-events'; /** * Component collects common behaviors to be followed by UI components, such @@ -73,15 +82,15 @@ import { EventEmitter, EventHandler } from 'metal-events'; class Component extends EventEmitter { /** * Constructor function for `Component`. - * @param {Object=} opt_config An object with the initial values for this + * @param {Object=} config An object with the initial values for this * component's state. - * @param {boolean|string|Element=} opt_parentElement The element where the + * @param {boolean|string|Element=} parentElement The element where the * component should be rendered. Can be given as a selector or an element. * If `false` is passed, the component won't be rendered automatically * after created. * @constructor */ - constructor(opt_config, opt_parentElement) { + constructor(config, parentElement) { super(); /** @@ -121,7 +130,7 @@ class Component extends EventEmitter { * @type {!Object} * @protected */ - this.initialConfig_ = opt_config || {}; + this.initialConfig_ = config || {}; /** * Whether the current environment is server side. @@ -158,8 +167,8 @@ class Component extends EventEmitter { this.created(); this.componentCreated_ = true; - if (opt_parentElement !== false) { - this.renderComponent(opt_parentElement); + if (parentElement !== false) { + this.renderComponent(parentElement); } } @@ -189,23 +198,24 @@ class Component extends EventEmitter { * appended to the DOM and any other action to be performed must be * implemented in this method, such as, binding DOM events. A component can * be re-attached multiple times. - * @param {(string|Element)=} opt_parentElement Optional parent element + * @param {(string|Element)=} parentElement Optional parent element * to render the component. - * @param {(string|Element)=} opt_siblingElement Optional sibling element + * @param {(string|Element)=} siblingElement Optional sibling element * to render the component before it. Relevant when the component needs * to be rendered before an existing element in the DOM. * @protected * @chainable + * @return {Component} */ - attach(opt_parentElement, opt_siblingElement) { + attach(parentElement, siblingElement) { if (!this.inDocument) { this.emit('willAttach'); this.willAttach(); - this.attachElement(opt_parentElement, opt_siblingElement); + this.attachElement(parentElement, siblingElement); this.inDocument = true; this.attachData_ = { - parent: opt_parentElement, - sibling: opt_siblingElement + parent: parentElement, + sibling: siblingElement, }; this.emit('attached', this.attachData_); this.attached(); @@ -224,18 +234,18 @@ class Component extends EventEmitter { /** * Attaches the component element into the DOM. - * @param {(string|Element)=} opt_parentElement Optional parent element + * @param {(string|Element)=} parentElement Optional parent element * to render the component. - * @param {(string|Element)=} opt_siblingElement Optional sibling element + * @param {(string|Element)=} siblingElement Optional sibling element * to render the component before it. Relevant when the component needs * to be rendered before an existing element in the DOM, e.g. * `component.attach(null, existingElement)`. */ - attachElement(opt_parentElement, opt_siblingElement) { + attachElement(parentElement, siblingElement) { const element = this.element; - if (element && (opt_siblingElement || !element.parentNode)) { - const parent = toElement(opt_parentElement) || this.DEFAULT_ELEMENT_PARENT; - parent.insertBefore(element, toElement(opt_siblingElement)); + if (element && (siblingElement || !element.parentNode)) { + const parent = toElement(parentElement) || this.DEFAULT_ELEMENT_PARENT; // eslint-disable-line + parent.insertBefore(element, toElement(siblingElement)); } } @@ -264,6 +274,7 @@ class Component extends EventEmitter { * implemented in this method, such as, unbinding DOM events. A component * can be detached multiple times. * @chainable + * @return {Component} */ detach() { if (this.inDocument) { @@ -316,12 +327,13 @@ class Component extends EventEmitter { /** * Forces an update that ignores the `shouldUpdate` lifecycle method for * components whose render depends on external variables. + * @param {function()} callback */ - forceUpdate(opt_callback) { - this.forceUpdateCallback_ = opt_callback; + forceUpdate(callback) { + this.forceUpdateCallback_ = callback; this.updateRenderer_({ - forceUpdate: true + forceUpdate: true, }); } @@ -384,7 +396,7 @@ class Component extends EventEmitter { if (this.componentCreated_) { this.emit('elementChanged', { prevVal, - newVal + newVal, }); if (newVal && this.wasRendered) { this.syncVisible(this.dataManager_.get(this, 'visible')); @@ -415,8 +427,8 @@ class Component extends EventEmitter { handleComponentStateKeyChanged_(data) { this.updateRenderer_({ changes: { - [data.key]: data - } + [data.key]: data, + }, }); } @@ -500,17 +512,16 @@ class Component extends EventEmitter { * will always make sure that the constructor runs without rendering the * component, having the `render` step happen only after it has finished. * @param {!function()} Ctor The component's constructor function. - * @param {Object|Element=} opt_configOrElement Optional config data or parent + * @param {Object|Element=} configOrElement Optional config data or parent * for the component. - * @param {Element=} opt_element Optional parent for the component. + * @param {Element=} element Optional parent for the component. * @return {!Component} The rendered component's instance. */ - static render(Ctor, opt_configOrElement, opt_element) { - let config = opt_configOrElement; - let element = opt_element; - if (isElement(opt_configOrElement)) { + static render(Ctor, configOrElement, element) { + let config = configOrElement; + if (isElement(configOrElement)) { config = null; - element = opt_configOrElement; + element = configOrElement; } const instance = new Ctor(config, false); instance.renderComponent(element); @@ -523,52 +534,56 @@ class Component extends EventEmitter { * rendering the component, having the `render` step happen only after it * has finished. * @param {!function()} Ctor The component's constructor function. - * @param {Object|Element=} opt_configOrElement Optional config data or + * @param {Object|Element=} configOrElement Optional config data or * parent for the component. * @return {!String} The rendered component's content as string. */ - static renderToString(Ctor, opt_config) { + static renderToString(Ctor, configOrElement) { const rendererName = Ctor.RENDERER && Ctor.RENDERER.RENDERER_NAME; switch (rendererName) { - case 'jsx': - case 'soy': - case 'incremental-dom': { - if (typeof IncrementalDOM === 'undefined') { - throw new Error(`Error. Trying to render incremental dom ` + - `based component to string requires IncrementalDOM ` + - `implementation to be loaded.`); - } - // Incremental dom patches for components or nested components are - // isolated inside the component element. The following code intercepts - // incremental dom patches and collect results into temporary stack in - // order to successfully collect the final string of the outermost - // component after all nested components stack rendered. - const interceptedComponentStrings = []; - const patch = IncrementalDOM.patch; - const patchInterceptor = function() { - let currentElement = patch.apply(null, arguments); - interceptedComponentStrings.push(currentElement.innerHTML); - IncrementalDOM.patch = patch; - }; - IncrementalDOM.patch = patchInterceptor; - Component.render(Ctor, opt_config).dispose(); - return interceptedComponentStrings[0]; + case 'jsx': + case 'soy': + case 'incremental-dom': { + if (typeof IncrementalDOM === 'undefined') { + throw new Error( + `Error. Trying to render incremental dom ` + + `based component to string requires IncrementalDOM ` + + `implementation to be loaded.` + ); } - default: - throw new Error(`Error. Trying to render non incremental dom ` + - `based component to string.`); + // Incremental dom patches for components or nested components are + // isolated inside the component element. The following code intercepts + // incremental dom patches and collect results into temporary stack in + // order to successfully collect the final string of the outermost + // component after all nested components stack rendered. + const interceptedComponentStrings = []; + const patch = IncrementalDOM.patch; + const patchInterceptor = function(...args) { + let currentElement = patch(...args); + interceptedComponentStrings.push(currentElement.innerHTML); + IncrementalDOM.patch = patch; + }; + IncrementalDOM.patch = patchInterceptor; + Component.render(Ctor, configOrElement).dispose(); + return interceptedComponentStrings[0]; + } + default: + throw new Error( + `Error. Trying to render non incremental dom ` + + `based component to string.` + ); } - }; + } /** * Renders the component into the DOM via its `ComponentRenderer`. Stores the * given parent element to be used when the renderer is done (`informRendered`). - * @param {(string|Element|boolean)=} opt_parentElement Optional parent element + * @param {(string|Element|boolean)=} parentElement Optional parent element * to render the component. If set to `false`, the element won't be * attached to any element after rendering. In this case, `attach` should * be called manually later to actually attach it to the dom. */ - renderComponent(opt_parentElement) { + renderComponent(parentElement) { if (!this.hasRendererRendered_) { if (!this.serverSide_ && window.__METAL_DEV_TOOLS_HOOK__) { window.__METAL_DEV_TOOLS_HOOK__(this); @@ -577,7 +592,7 @@ class Component extends EventEmitter { } this.emit('render'); syncState(this); - this.attach(opt_parentElement); + this.attach(parentElement); this.wasRendered = true; } @@ -603,13 +618,13 @@ class Component extends EventEmitter { /** * Sets the value of all the specified state keys. - * @param {!Object.} values A map of state keys to the values they + * @param {!Object.} state A map of state keys to the values they * should be set to. - * @param {function()=} opt_callback An optional function that will be run + * @param {function()=} callback An optional function that will be run * after the next batched update is triggered. */ - setState(state, opt_callback) { - this.dataManager_.setState(this, state, opt_callback); + setState(state, callback) { + this.dataManager_.setState(this, state, callback); } /** @@ -639,7 +654,7 @@ class Component extends EventEmitter { this.dataManager_ = getStaticProperty(this.constructor, 'DATA_MANAGER'); this.dataManager_.setUp( this, - object.mixin({}, this.renderer_.getExtraDataConfig(this), Component.DATA) + object.mixin({}, this.renderer_.getExtraDataConfig(this), Component.DATA) // eslint-disable-line ); } @@ -761,7 +776,7 @@ Component.DATA = { */ children: { validator: Array.isArray, - value: [] + value: [], }, /** @@ -771,7 +786,7 @@ Component.DATA = { elementClasses: { setter: 'setterElementClassesFn_', validator: isString, - value: '' + value: '', }, /** @@ -782,7 +797,7 @@ Component.DATA = { */ events: { validator: 'validatorEventsFn_', - value: null + value: null, }, /** @@ -791,8 +806,8 @@ Component.DATA = { */ visible: { validator: isBoolean, - value: true - } + value: true, + }, }; /** @@ -840,7 +855,7 @@ Component.prototype[Component.COMPONENT_FLAG] = true; const proxyBlackList_ = { eventsChanged: true, stateChanged: true, - stateKeyChanged: true + stateKeyChanged: true, }; export default Component; diff --git a/packages/metal-component/src/ComponentDataManager.js b/packages/metal-component/src/ComponentDataManager.js index 54c332fd..afb91b5e 100644 --- a/packages/metal-component/src/ComponentDataManager.js +++ b/packages/metal-component/src/ComponentDataManager.js @@ -1,6 +1,6 @@ 'use strict'; -import { object } from 'metal'; +import {object} from 'metal'; import State from 'metal-state'; const BLACKLIST = { @@ -10,10 +10,13 @@ const BLACKLIST = { refs: true, state: true, stateKey: true, - wasRendered: true + wasRendered: true, }; const DATA_MANAGER_DATA = '__DATA_MANAGER_DATA__'; +/** + * Class to handle Component Data + */ class ComponentDataManager { /** * Creates the `State` instance that will handle the main component data. @@ -22,7 +25,7 @@ class ComponentDataManager { * @protected */ createState_(component, data) { - const state = new State(component.getInitialConfig(), component, component); + const state = new State(component.getInitialConfig(), component, component); // eslint-disable-line state.setKeysBlacklist(BLACKLIST); state.configState( object.mixin({}, data, State.getStateStatic(component.constructor)) @@ -102,10 +105,13 @@ class ComponentDataManager { * value if none is given). * @param {!Component} component * @param {!Object} data - * @param {State=} opt_state + * @param {State=} state */ - replaceNonInternal(component, data, opt_state) { - const state = opt_state || this.getManagerData(component).state_; + replaceNonInternal( + component, + data, + state = this.getManagerData(component).state_ + ) { const keys = state.getStateKeys(); for (let i = 0; i < keys.length; i++) { const key = keys[i]; @@ -122,13 +128,13 @@ class ComponentDataManager { /** * Sets the value of all the specified state keys. * @param {!Component} component - * @param {!Object.} values A map of state keys to the values they + * @param {!Object.} state A map of state keys to the values they * should be set to. - * @param {function()=} opt_callback An optional function that will be run + * @param {function()=} callback An optional function that will be run * after the next batched update is triggered. */ - setState(component, state, opt_callback) { - this.getManagerData(component).state_.setState(state, opt_callback); + setState(component, state, callback) { + this.getManagerData(component).state_.setState(state, callback); } /** diff --git a/packages/metal-component/src/ComponentRegistry.js b/packages/metal-component/src/ComponentRegistry.js index bf942d8a..959bed84 100644 --- a/packages/metal-component/src/ComponentRegistry.js +++ b/packages/metal-component/src/ComponentRegistry.js @@ -1,6 +1,6 @@ 'use strict'; -import { getFunctionName } from 'metal'; +import {getFunctionName} from 'metal'; /** * The component registry is used to register components, so they can @@ -29,13 +29,12 @@ class ComponentRegistry { /** * Registers a component, so it can be found by its name. * @param {!Function} constructorFn The component's constructor function. - * @param {string=} opt_name Name of the registered component. If none is given + * @param {string=} name Name of the registered component. If none is given * the name defined by the NAME static variable will be used instead. If that * isn't set as well, the name of the constructor function will be used. * @static */ - static register(constructorFn, opt_name) { - let name = opt_name; + static register(constructorFn, name) { if (!name) { if (constructorFn.hasOwnProperty('NAME')) { name = constructorFn.NAME; diff --git a/packages/metal-component/src/ComponentRenderer.js b/packages/metal-component/src/ComponentRenderer.js index 343fbb6c..b2b07e0a 100644 --- a/packages/metal-component/src/ComponentRenderer.js +++ b/packages/metal-component/src/ComponentRenderer.js @@ -5,7 +5,6 @@ * required methods all renderers should have. */ class ComponentRenderer { - /** * Disposes of any data specific to the given component. * @param {!Component} component @@ -17,7 +16,6 @@ class ComponentRenderer { * Sub classes can override to return `State` config for properties that * should be added to the component. * @param {!Component} component - * @return {Object} */ getExtraDataConfig() {} diff --git a/packages/metal-component/src/all/component.js b/packages/metal-component/src/all/component.js index a16228a1..5735f850 100644 --- a/packages/metal-component/src/all/component.js +++ b/packages/metal-component/src/all/component.js @@ -6,5 +6,10 @@ import ComponentRegistry from '../ComponentRegistry'; import ComponentRenderer from '../ComponentRenderer'; export default Component; -export { Component, ComponentDataManager, ComponentRegistry, ComponentRenderer }; +export { + Component, + ComponentDataManager, + ComponentRegistry, + ComponentRenderer, +}; export * from '../events/events'; diff --git a/packages/metal-component/src/events/events.js b/packages/metal-component/src/events/events.js index bb36a65d..7c3b351b 100644 --- a/packages/metal-component/src/events/events.js +++ b/packages/metal-component/src/events/events.js @@ -1,6 +1,6 @@ 'use strict'; -import { getFunctionName, isFunction, isObject, isString } from 'metal'; +import {getFunctionName, isFunction, isObject, isString} from 'metal'; /** * Adds the listeners specified in the given object. @@ -16,7 +16,7 @@ export function addListenersFromObj(component, events) { if (info.fn) { let handle; if (info.selector) { - handle = component.delegate(eventNames[i], info.selector, info.fn); + handle = component.delegate(eventNames[i], info.selector, info.fn); // eslint-disable-line } else { handle = component.on(eventNames[i], info.fn); } @@ -29,14 +29,13 @@ export function addListenersFromObj(component, events) { /** * Extracts listener info from the given value. * @param {!Component} component - * @param {!Component} component - * @param {function()|string|{selector:string,fn:function()|string}} value + * @param {function()|string|{selector:string,fn:function()}|string} value * @return {!{selector:string,fn:function()}} * @protected */ function extractListenerInfo_(component, value) { const info = { - fn: value + fn: value, }; if (isObject(value) && !isFunction(value)) { info.selector = value.selector; @@ -60,7 +59,6 @@ export function getComponentFn(component, fnName) { } else { console.error(`No function named ${fnName} was found in the component "${getFunctionName(component.constructor)}". Make sure that you specify - valid function names when adding inline listeners` - ); + valid function names when adding inline listeners`); } } diff --git a/packages/metal-component/src/sync/sync.js b/packages/metal-component/src/sync/sync.js index fe515e24..f6fcccc6 100644 --- a/packages/metal-component/src/sync/sync.js +++ b/packages/metal-component/src/sync/sync.js @@ -1,6 +1,6 @@ 'use strict'; -import { isFunction } from 'metal'; +import {isFunction} from 'metal'; const SYNC_FNS_KEY = '__METAL_SYNC_FNS__'; @@ -41,16 +41,16 @@ function getSyncFns_(component) { /** * Calls "sync" functions for the given component's state. * @param {!Component} component - * @param {Object=} opt_changes When given, only the properties inside it will + * @param {Object=} changes When given, only the properties inside it will * be synced. Otherwise all state properties will be synced. */ -export function syncState(component, opt_changes) { +export function syncState(component, changes) { const syncFns = getSyncFns_(component); - const keys = Object.keys(opt_changes || syncFns); + const keys = Object.keys(changes || syncFns); for (let i = 0; i < keys.length; i++) { const fn = syncFns[keys[i]]; if (isFunction(fn)) { - const change = opt_changes && opt_changes[keys[i]]; + const change = changes && changes[keys[i]]; const manager = component.getDataManager(); fn.call( component, diff --git a/packages/metal-events/test/.eslintrc.json b/packages/metal-component/test/.eslintrc similarity index 60% rename from packages/metal-events/test/.eslintrc.json rename to packages/metal-component/test/.eslintrc index 92b466f1..902156c0 100644 --- a/packages/metal-events/test/.eslintrc.json +++ b/packages/metal-component/test/.eslintrc @@ -5,5 +5,9 @@ "globals": { "assert": true, "sinon": true + }, + "rules": { + "max-len": 0, + "require-jsdoc": 0 } -} +} \ No newline at end of file diff --git a/packages/metal-component/test/Component.js b/packages/metal-component/test/Component.js index 4fc59a0a..a94d2a69 100644 --- a/packages/metal-component/test/Component.js +++ b/packages/metal-component/test/Component.js @@ -1,14 +1,14 @@ 'use strict'; -import { async, core } from 'metal'; -import { dom, features } from 'metal-dom'; -import { validators } from 'metal-state'; +import {async, core} from 'metal'; +import {dom, features} from 'metal-dom'; +import {validators} from 'metal-state'; import Component from '../src/Component'; import ComponentDataManager from '../src/ComponentDataManager'; import ComponentRenderer from '../src/ComponentRenderer'; describe('Component', function() { - var comp; + let comp; afterEach(function() { document.body.innerHTML = ''; @@ -37,7 +37,7 @@ describe('Component', function() { }); it('should run component render lifecycle', function() { - var renderListener = sinon.stub(); + let renderListener = sinon.stub(); class TestComponent extends Component { created() { this.on('render', renderListener); @@ -57,7 +57,7 @@ describe('Component', function() { }); it('should not run component render lifecycle if "false" is passed as second param', function() { - var renderListener = sinon.stub(); + let renderListener = sinon.stub(); class TestComponent extends Component { created() { this.on('render', renderListener); @@ -95,8 +95,7 @@ describe('Component', function() { }); it('should run "willAttach" lifecycle method when the component is about to attach', function() { - class TestComponent extends Component { - } + class TestComponent extends Component {} sinon.spy(TestComponent.prototype, 'willAttach'); comp = new TestComponent(); @@ -105,7 +104,7 @@ describe('Component', function() { }); it('should emit "willAttach" lifecycle event when the component is about to attach', function() { - var listener = sinon.stub(); + let listener = sinon.stub(); class TestComponent extends Component { created() { this.on('willAttach', listener); @@ -119,7 +118,7 @@ describe('Component', function() { it('should emit "attached" event when component is attached', function() { comp = new Component({}, false); - var listener = sinon.stub(); + let listener = sinon.stub(); comp.on('attached', listener); comp.attach('.parent', '.sibling'); assert.strictEqual(1, listener.callCount); @@ -130,15 +129,14 @@ describe('Component', function() { it('should return attach data via the `getAttachData` function', function() { comp = new Component({}, false); comp.attach('.parent', '.sibling'); - var attachData = comp.getAttachData(); + let attachData = comp.getAttachData(); assert.ok(attachData); assert.strictEqual('.parent', attachData.parent); assert.strictEqual('.sibling', attachData.sibling); }); it('should run "rendered" lifecycle method when the component is rendered', function() { - class TestComponent extends Component { - } + class TestComponent extends Component {} sinon.spy(TestComponent.prototype, 'rendered'); comp = new TestComponent(); @@ -147,7 +145,7 @@ describe('Component', function() { }); it('should emit "rendered" event when the component is rendered', function() { - var listener = sinon.stub(); + let listener = sinon.stub(); class TestComponent extends Component { created() { this.on('rendered', listener); @@ -166,8 +164,7 @@ describe('Component', function() { }); it('should run "willDetach" lifecycle method when the component is about to detach', function() { - class TestComponent extends Component { - } + class TestComponent extends Component {} sinon.spy(TestComponent.prototype, 'willDetach'); comp = new TestComponent(); @@ -180,7 +177,7 @@ describe('Component', function() { }); it('should emit "willDetach" lifecycle event when the component is about to detach', function() { - var listener = sinon.stub(); + let listener = sinon.stub(); class TestComponent extends Component { created() { this.on('willDetach', listener); @@ -200,7 +197,7 @@ describe('Component', function() { comp = new Component(); assert.ok(comp.element.parentNode); - var element = comp.element; + let element = comp.element; comp.dispose(); assert.ok(!element.parentNode); @@ -229,33 +226,33 @@ describe('Component', function() { }); it('should set component element', function() { - var element = document.createElement('div'); + let element = document.createElement('div'); document.body.appendChild(element); comp = new Component({ - element: element + element: element, }); assert.strictEqual(element, comp.element); }); it('should set component element from selector', function() { - var element = document.createElement('div'); + let element = document.createElement('div'); element.className = 'myClass'; document.body.appendChild(element); comp = new Component({ - element: '.myClass' + element: '.myClass', }); assert.strictEqual(element, comp.element); }); it('should keep previous element if selector doesn\'t match anything', function() { comp = new Component({ - element: '.myClass' + element: '.myClass', }); assert.ok(comp.element); - var element = document.createElement('div'); + let element = document.createElement('div'); comp.element = element; assert.strictEqual(element, comp.element); @@ -273,18 +270,18 @@ describe('Component', function() { describe('State', function() { it('should merge elementClasses with ELEMENT_CLASSES static hint', function() { - var CustomComponent = createCustomComponentClass(); + let CustomComponent = createCustomComponentClass(); CustomComponent.ELEMENT_CLASSES = 'static'; comp = new CustomComponent({ - elementClasses: 'class' + elementClasses: 'class', }); assert.strictEqual('class static', comp.elementClasses); }); it('should allow setting element to null', function() { comp = new Component(); - assert.doesNotThrow(() => comp.element = null); + assert.doesNotThrow(() => (comp.element = null)); assert.strictEqual(null, comp.element); }); @@ -295,7 +292,9 @@ describe('Component', function() { assert.ok(!comp.inDocument); }); - it('should update element display value according to visible state', function(done) { + it('should update element display value according to visible state', function( + done + ) { comp = new Component(); assert.ok(comp.visible); @@ -314,13 +313,15 @@ describe('Component', function() { it('should set display value on new element when changed', function() { comp = new Component({ - visible: false + visible: false, }); comp.element = document.createElement('div'); assert.strictEqual('none', comp.element.style.display); }); - it('should not throw error when trying to set display value before element is set', function(done) { + it('should not throw error when trying to set display value before element is set', function( + done + ) { comp = new Component({}, false); comp.visible = false; comp.once('stateSynced', function() { @@ -330,26 +331,26 @@ describe('Component', function() { }); it('should return initial config object received by the constructor', function() { - var config = {}; + let config = {}; comp = new Component(config); assert.strictEqual(config, comp.getInitialConfig()); }); it('should return an array with all state property names', function() { comp = new Component(); - var expected = ['children', 'elementClasses', 'events', 'visible']; + let expected = ['children', 'elementClasses', 'events', 'visible']; assert.deepEqual(expected, comp.getStateKeys().sort()); }); it('should return an object with all state properties', function() { comp = new Component({ - elementClasses: 'myClass' + elementClasses: 'myClass', }); - var expected = { + let expected = { children: [], elementClasses: 'myClass', events: null, - visible: true + visible: true, }; assert.deepEqual(expected, comp.getState()); }); @@ -358,7 +359,7 @@ describe('Component', function() { comp = new Component(); comp.setState({ elementClasses: 'myClass', - visible: false + visible: false, }); assert.strictEqual('myClass', comp.elementClasses); assert.ok(!comp.visible); @@ -366,15 +367,15 @@ describe('Component', function() { describe('events state key', function() { it('should attach events to specified functions', function() { - var CustomComponent = createCustomComponentClass(); + let CustomComponent = createCustomComponentClass(); CustomComponent.prototype.listener1 = sinon.stub(); const listener2 = sinon.stub(); comp = new CustomComponent({ events: { event1: 'listener1', - event2: listener2 - } + event2: listener2, + }, }); comp.emit('event1'); @@ -387,13 +388,13 @@ describe('Component', function() { }); it('should attach events when "events" state property value changes', function() { - var listener1 = sinon.stub(); - var listener2 = sinon.stub(); + let listener1 = sinon.stub(); + let listener2 = sinon.stub(); comp = new Component(); comp.events = { event1: listener1, - event2: listener2 + event2: listener2, }; comp.emit('event1'); @@ -406,17 +407,17 @@ describe('Component', function() { }); it('should detach unused events when value of the "events" state key is changed', function() { - var CustomComponent = createCustomComponentClass(); + let CustomComponent = createCustomComponentClass(); CustomComponent.prototype.listener1 = sinon.stub(); CustomComponent.prototype.listener2 = sinon.stub(); comp = new CustomComponent({ events: { - event1: 'listener1' - } + event1: 'listener1', + }, }); comp.events = { - event2: 'listener2' + event2: 'listener2', }; comp.emit('event1'); @@ -427,18 +428,20 @@ describe('Component', function() { }); }); - it('should synchronize state synchronously on render and asynchronously when state value changes', function(done) { - var CustomComponent = createCustomComponentClass(); + it('should synchronize state synchronously on render and asynchronously when state value changes', function( + done + ) { + let CustomComponent = createCustomComponentClass(); CustomComponent.STATE = { foo: { - value: 0 - } + value: 0, + }, }; CustomComponent.prototype.syncUnkown = sinon.spy(); CustomComponent.prototype.syncFoo = sinon.spy(); comp = new CustomComponent({ - foo: 10 + foo: 10, }); sinon.assert.notCalled(CustomComponent.prototype.syncUnkown); sinon.assert.callCount(CustomComponent.prototype.syncFoo, 1); @@ -460,21 +463,20 @@ describe('Component', function() { }); it('should fire sync methods for state keys defined by super classes as well', function() { - var CustomComponent = createCustomComponentClass(); + let CustomComponent = createCustomComponentClass(); CustomComponent.STATE = { foo: { - value: 0 - } + value: 0, + }, }; - class ChildComponent extends CustomComponent { - } + class ChildComponent extends CustomComponent {} ChildComponent.prototype.syncFoo = sinon.spy(); ChildComponent.prototype.syncBar = sinon.spy(); ChildComponent.STATE = { bar: { - value: 1 - } + value: 1, + }, }; comp = new ChildComponent(); @@ -482,16 +484,18 @@ describe('Component', function() { sinon.assert.callCount(comp.syncBar, 1); }); - it('should emit "stateSynced" event after state changes update the component', function(done) { - var CustomComponent = createCustomComponentClass(); + it('should emit "stateSynced" event after state changes update the component', function( + done + ) { + let CustomComponent = createCustomComponentClass(); CustomComponent.STATE = { foo: { - value: 0 - } + value: 0, + }, }; comp = new CustomComponent(); - var listener = sinon.stub(); + let listener = sinon.stub(); comp.on('stateSynced', listener); comp.foo = 1; comp.once('stateChanged', function(data) { @@ -501,19 +505,20 @@ describe('Component', function() { }); }); - it('should emit "rendered" event with "false" as the first arg when updated by the renderer', function(done) { + it('should emit "rendered" event with "false" as the first arg when updated by the renderer', function( + done + ) { class CustomRenderer extends ComponentRenderer.constructor { update(component) { component.informRendered(); } } - class TestComponent extends Component { - } + class TestComponent extends Component {} TestComponent.RENDERER = new CustomRenderer(); comp = new TestComponent(); - var listener = sinon.stub(); + let listener = sinon.stub(); comp.on('rendered', listener); comp.visible = false; @@ -525,9 +530,9 @@ describe('Component', function() { }); it('should not allow defining state key named components', function() { - var CustomComponent = createCustomComponentClass(); + let CustomComponent = createCustomComponentClass(); CustomComponent.STATE = { - components: {} + components: {}, }; assert.throws(function() { @@ -535,7 +540,9 @@ describe('Component', function() { }); }); - it('should allow changes to state in "willReceiveState" without triggering multiple renders', function(done) { + it('should allow changes to state in "willReceiveState" without triggering multiple renders', function( + done + ) { const renderStub = sinon.stub(); let count = 0; @@ -549,7 +556,7 @@ describe('Component', function() { } class TestComponent extends Component { - willReceiveState(changes) { + willReceiveState() { this.foo = 'foo' + count; count++; @@ -557,12 +564,12 @@ describe('Component', function() { } TestComponent.STATE = { bar: { - value: 'bar' + value: 'bar', }, foo: { - value: 'foo' - } + value: 'foo', + }, }; TestComponent.RENDERER = new CustomRenderer(); @@ -584,14 +591,15 @@ describe('Component', function() { }); }); - it('should pass changed state data to "willReceiveState" method', function(done) { - class TestComponent extends Component { - } + it('should pass changed state data to "willReceiveState" method', function( + done + ) { + class TestComponent extends Component {} TestComponent.prototype.willReceiveState = sinon.stub(); TestComponent.STATE = { foo: { - value: 'foo' - } + value: 'foo', + }, }; comp = new TestComponent(); @@ -604,8 +612,8 @@ describe('Component', function() { foo: { key: 'foo', newVal: 'foo2', - prevVal: 'foo' - } + prevVal: 'foo', + }, }); done(); @@ -615,13 +623,13 @@ describe('Component', function() { describe('Render', function() { it('should render component on body if no parent is specified', function() { - var CustomComponent = createCustomComponentClass(); + let CustomComponent = createCustomComponentClass(); comp = new CustomComponent(); assert.strictEqual(document.body, comp.element.parentNode); }); it('should render component on specified default parent if no parent is specified', function() { - var defaultParent = document.createElement('div'); + let defaultParent = document.createElement('div'); class CustomComponent extends Component { created() { @@ -633,20 +641,20 @@ describe('Component', function() { }); it('should render component on requested parent', function() { - var container = document.createElement('div'); + let container = document.createElement('div'); document.body.appendChild(container); - var CustomComponent = createCustomComponentClass(); + let CustomComponent = createCustomComponentClass(); comp = new CustomComponent({}, container); assert.strictEqual(container, comp.element.parentNode); }); it('should render component on requested parent selector', function() { - var container = document.createElement('div'); + let container = document.createElement('div'); container.className = 'myContainer'; document.body.appendChild(container); - var CustomComponent = createCustomComponentClass(); + let CustomComponent = createCustomComponentClass(); comp = new CustomComponent({}, '.myContainer'); assert.strictEqual(container, comp.element.parentNode); }); @@ -659,11 +667,11 @@ describe('Component', function() { } } - var container = document.createElement('div'); + let container = document.createElement('div'); comp = Component.render( CustomComponent, { - foo: 'fooValue' + foo: 'fooValue', }, container ); @@ -676,8 +684,7 @@ describe('Component', function() { }); it('should throw error when rendering non-incremental-dom component via Component.renderToString', function() { - class NotIncrementalDomComponent extends Component { - } + class NotIncrementalDomComponent extends Component {} assert.throws(function() { Component.renderToString(NotIncrementalDomComponent); }); @@ -691,11 +698,8 @@ describe('Component', function() { } } - var container = document.createElement('div'); - comp = Component.render( - CustomComponent, - container - ); + let container = document.createElement('div'); + comp = Component.render(CustomComponent, container); assert.ok(comp instanceof CustomComponent); assert.ok(comp.wasRendered); @@ -704,14 +708,14 @@ describe('Component', function() { }); it('should attach component on requested parent at specified position', function() { - var container = document.createElement('div'); - var sibling1 = document.createElement('div'); - var sibling2 = document.createElement('div'); + let container = document.createElement('div'); + let sibling1 = document.createElement('div'); + let sibling2 = document.createElement('div'); container.appendChild(sibling1); container.appendChild(sibling2); document.body.appendChild(container); - var CustomComponent = createCustomComponentClass(); + let CustomComponent = createCustomComponentClass(); comp = new CustomComponent(); comp.detach(); comp.attach(container, sibling2); @@ -722,15 +726,15 @@ describe('Component', function() { }); it('should attach component according to specified sibling selector', function() { - var container = document.createElement('div'); - var sibling1 = document.createElement('div'); - var sibling2 = document.createElement('div'); + let container = document.createElement('div'); + let sibling1 = document.createElement('div'); + let sibling2 = document.createElement('div'); sibling2.className = 'mySibling'; container.appendChild(sibling1); container.appendChild(sibling2); document.body.appendChild(container); - var CustomComponent = createCustomComponentClass(); + let CustomComponent = createCustomComponentClass(); comp = new CustomComponent(); comp.detach(); comp.attach(container, '.mySibling'); @@ -743,7 +747,7 @@ describe('Component', function() { describe('Updates', function() { it('should call renderer\'s update method if state changes', function(done) { - var CustomComponent = createCustomComponentClass(); + let CustomComponent = createCustomComponentClass(); comp = new CustomComponent(); const renderer = comp.getRenderer(); sinon.spy(renderer, 'update'); @@ -755,8 +759,10 @@ describe('Component', function() { }); }); - it('should not call renderer\'s update method if state changes before render', function(done) { - var CustomComponent = createCustomComponentClass(); + it('should not call renderer\'s update method if state changes before render', function( + done + ) { + let CustomComponent = createCustomComponentClass(); comp = new CustomComponent({}, false); const renderer = comp.getRenderer(); sinon.spy(renderer, 'update'); @@ -768,8 +774,10 @@ describe('Component', function() { }); }); - it('should not call renderer\'s update method if state changes while skipping updates', function(done) { - var CustomComponent = createCustomComponentClass(); + it('should not call renderer\'s update method if state changes while skipping updates', function( + done + ) { + let CustomComponent = createCustomComponentClass(); comp = new CustomComponent(); const renderer = comp.getRenderer(); sinon.spy(renderer, 'update'); @@ -802,15 +810,17 @@ describe('Component', function() { visible: { key: 'visible', prevVal: true, - newVal: false - } + newVal: false, + }, }; assert.strictEqual(1, renderer.update.callCount); assert.strictEqual(comp, renderer.update.args[0][0]); assert.deepEqual(expectedData, renderer.update.args[0][1].changes); }); - it('should not call the renderer\'s update method asynchronously if state changes', function(done) { + it('should not call the renderer\'s update method asynchronously if state changes', function( + done + ) { const CustomComponent = createCustomComponentClass(); CustomComponent.SYNC_UPDATES = true; @@ -839,10 +849,10 @@ describe('Component', function() { }); it('should invoke the "forceUpdate" callback argument after the rerender has completed', function() { - var CustomComponent = createCustomComponentClass(); + let CustomComponent = createCustomComponentClass(); comp = new CustomComponent(); - var listener = sinon.stub(); + let listener = sinon.stub(); comp.forceUpdate(listener); @@ -862,9 +872,9 @@ describe('Component', function() { it('should listen to events on the element through Component\'s "on" function', function() { comp = new Component(); - var element = comp.element; + let element = comp.element; element.onclick = null; - var listener = sinon.stub(); + let listener = sinon.stub(); comp.on('click', listener); dom.triggerEvent(element, 'click'); @@ -876,11 +886,13 @@ describe('Component', function() { }); it('should listen to delegate events on the element', function() { - var CustomComponent = createCustomComponentClass('
'); + let CustomComponent = createCustomComponentClass( + '
' + ); comp = new CustomComponent(); - var fooElement = comp.element.querySelector('.foo'); - var listener = sinon.stub(); + let fooElement = comp.element.querySelector('.foo'); + let listener = sinon.stub(); comp.delegate('click', '.foo', listener); dom.triggerEvent(fooElement, 'click'); @@ -892,23 +904,26 @@ describe('Component', function() { }); it('should listen to custom events on the element', function() { - var CustomComponent = createCustomComponentClass(); + let CustomComponent = createCustomComponentClass(); comp = new CustomComponent(); - var listener = sinon.stub(); + let listener = sinon.stub(); comp.on('transitionend', listener); - dom.triggerEvent(comp.element, features.checkAnimationEventName().transition); + dom.triggerEvent( + comp.element, + features.checkAnimationEventName().transition + ); assert.strictEqual(1, listener.callCount); }); it('should transfer events listened through "on" function to new element', function() { comp = new Component(); - var element = comp.element; - var listener = sinon.stub(); + let element = comp.element; + let listener = sinon.stub(); comp.on('click', listener); - var newElement = document.createElement('div'); + let newElement = document.createElement('div'); dom.enterDocument(newElement); comp.element = newElement; @@ -924,14 +939,16 @@ describe('Component', function() { }); it('should transfer delegate events listened on the component to the new element', function() { - var CustomComponent = createCustomComponentClass('
'); + let CustomComponent = createCustomComponentClass( + '
' + ); comp = new CustomComponent(); - var fooElement = comp.element.querySelector('.foo'); - var listener = sinon.stub(); + let fooElement = comp.element.querySelector('.foo'); + let listener = sinon.stub(); comp.delegate('click', '.foo', listener); - var newElement = document.createElement('div'); + let newElement = document.createElement('div'); dom.enterDocument(newElement); comp.element = newElement; dom.append(newElement, '
'); @@ -939,7 +956,7 @@ describe('Component', function() { dom.triggerEvent(fooElement, 'click'); assert.strictEqual(0, listener.callCount); - var newFooElement = newElement.querySelector('.foo'); + let newFooElement = newElement.querySelector('.foo'); dom.triggerEvent(newFooElement, 'click'); assert.strictEqual(1, listener.callCount); @@ -950,7 +967,7 @@ describe('Component', function() { it('should not reattach element listeners if its set to itself again', function() { comp = new Component(); - var listener = sinon.stub(); + let listener = sinon.stub(); comp.on('click', listener); comp.element.removeEventListener = sinon.stub(); @@ -961,10 +978,10 @@ describe('Component', function() { it('should listen to events on the element even before it\'s created', function() { comp = new Component({}, false); - var listener = sinon.stub(); + let listener = sinon.stub(); comp.on('click', listener); - var element = document.createElement('div'); + let element = document.createElement('div'); dom.enterDocument(element); comp.element = element; dom.triggerEvent(element, 'click'); @@ -973,10 +990,10 @@ describe('Component', function() { it('should listen to delegate events on the element even before it\'s created', function() { comp = new Component({}, false); - var listener = sinon.stub(); + let listener = sinon.stub(); comp.delegate('click', '.foo', listener); - var element = document.createElement('div'); + let element = document.createElement('div'); dom.enterDocument(element); dom.append(element, '
'); comp.element = element; @@ -987,11 +1004,11 @@ describe('Component', function() { it('should not reatach element listeners that were detached when element changes', function() { comp = new Component(); - var listener = sinon.stub(); - var handle = comp.on('click', listener); + let listener = sinon.stub(); + let handle = comp.on('click', listener); handle.removeListener(); - var newElement = document.createElement('div'); + let newElement = document.createElement('div'); comp.element = newElement; dom.triggerEvent(newElement, 'click'); @@ -999,14 +1016,16 @@ describe('Component', function() { }); it('should not reatach delegate listeners that were detached when element changes', function() { - var CustomComponent = createCustomComponentClass('
'); + let CustomComponent = createCustomComponentClass( + '
' + ); comp = new CustomComponent(); - var listener = sinon.stub(); - var handle = comp.delegate('click', '.foo', listener); + let listener = sinon.stub(); + let handle = comp.delegate('click', '.foo', listener); handle.removeListener(); - var newElement = document.createElement('div'); + let newElement = document.createElement('div'); comp.element = newElement; dom.append(newElement, '
'); @@ -1015,11 +1034,11 @@ describe('Component', function() { }); it('should be able to detach element listener that was attached before element changed', function() { - var comp = new Component(); - var listener = sinon.stub(); - var handle = comp.on('click', listener); + let comp = new Component(); + let listener = sinon.stub(); + let handle = comp.on('click', listener); - var newElement = document.createElement('div'); + let newElement = document.createElement('div'); comp.element = newElement; handle.removeListener(); @@ -1028,13 +1047,15 @@ describe('Component', function() { }); it('should be able to detach delegate listener that was attached before element changed', function() { - var CustomComponent = createCustomComponentClass('
'); + let CustomComponent = createCustomComponentClass( + '
' + ); comp = new CustomComponent(); - var listener = sinon.stub(); - var handle = comp.delegate('click', '.foo', listener); + let listener = sinon.stub(); + let handle = comp.delegate('click', '.foo', listener); - var newElement = document.createElement('div'); + let newElement = document.createElement('div'); comp.element = newElement; dom.append(newElement, '
'); @@ -1056,50 +1077,44 @@ describe('Component', function() { }); it('should warn if validator fails on initial value', function() { - class TestComponent extends Component { - } + class TestComponent extends Component {} TestComponent.STATE = { foo: { - validator: validators.string - } + validator: validators.string, + }, }; comp = new TestComponent({ - foo: 10 + foo: 10, }); assert.strictEqual(1, console.error.callCount); }); }); it('should get the renderer instance', function() { - class TestComponent extends Component { - } + class TestComponent extends Component {} comp = new TestComponent(); - var renderer = comp.getRenderer(); + let renderer = comp.getRenderer(); assert.ok(renderer instanceof ComponentRenderer.constructor); }); it('should get the data manager', function() { - class TestComponent extends Component { - } + class TestComponent extends Component {} comp = new TestComponent(); assert.strictEqual(ComponentDataManager, comp.getDataManager()); }); it('should check if the given function is a component constructor', function() { - class TestComponent extends Component { - } + class TestComponent extends Component {} assert.ok(Component.isComponentCtor(Component)); assert.ok(Component.isComponentCtor(TestComponent)); - assert.ok(!Component.isComponentCtor(() => { - })); - var fn = () => { - }; - assert.ok(!Component.isComponentCtor(fn.bind(this))); + assert.ok(!Component.isComponentCtor(() => {})); + let fn = () => {}; + assert.ok(!Component.isComponentCtor(fn.bind(this))); // eslint-disable-line }); it('should pass instance of component to __METAL_DEV_TOOLS_HOOK__ on first render', function() { - var hookStub = sinon.stub(); + let hookStub = sinon.stub(); window.__METAL_DEV_TOOLS_HOOK__ = hookStub; class CustomComponent extends Component { constructor(...args) { @@ -1122,21 +1137,20 @@ describe('Component', function() { sinon.assert.calledWith(hookStub, comp); }); - function createCustomComponentClass(opt_rendererContentOrFn) { - class CustomComponent extends Component { - } - CustomComponent.RENDERER = createCustomRenderer(opt_rendererContentOrFn); + function createCustomComponentClass(rendererContentOrFn) { + class CustomComponent extends Component {} + CustomComponent.RENDERER = createCustomRenderer(rendererContentOrFn); return CustomComponent; } - function createCustomRenderer(opt_rendererContentOrFn) { + function createCustomRenderer(rendererContentOrFn) { class CustomRenderer extends ComponentRenderer.constructor { render(component) { super.render(component); - if (core.isFunction(opt_rendererContentOrFn)) { - opt_rendererContentOrFn(); + if (core.isFunction(rendererContentOrFn)) { + rendererContentOrFn(); } else { - component.element.innerHTML = opt_rendererContentOrFn; + component.element.innerHTML = rendererContentOrFn; } } } diff --git a/packages/metal-component/test/ComponentDataManager.js b/packages/metal-component/test/ComponentDataManager.js index d770fcb4..76cd03c9 100644 --- a/packages/metal-component/test/ComponentDataManager.js +++ b/packages/metal-component/test/ComponentDataManager.js @@ -25,31 +25,30 @@ describe('ComponentDataManager', function() { it('should add the specified properties to the given component', function() { ComponentDataManager.setUp(component, { foo: { - value: 'fooValue' - } + value: 'fooValue', + }, }); assert.strictEqual('fooValue', component.foo); }); it('should use component\'s config as initial state values', function() { initialConfig = { - foo: 'initialFoo' + foo: 'initialFoo', }; ComponentDataManager.setUp(component, { - foo: { - } + foo: {}, }); assert.strictEqual('initialFoo', component.foo); }); it('should use default state value when "undefined" is passed as initial value', function() { initialConfig = { - foo: undefined + foo: undefined, }; ComponentDataManager.setUp(component, { foo: { - value: 'defaultFoo' - } + value: 'defaultFoo', + }, }); assert.strictEqual(component.foo, 'defaultFoo'); @@ -58,8 +57,7 @@ describe('ComponentDataManager', function() { it('should throw error if attempting to add state property named "element"', function() { assert.throws(() => { ComponentDataManager.setUp(component, { - element: { - } + element: {}, }); }); }); @@ -67,8 +65,8 @@ describe('ComponentDataManager', function() { it('should add the state properties defined in STATE to the given component', function() { component.constructor.STATE = { foo: { - value: 'fooValue' - } + value: 'fooValue', + }, }; ComponentDataManager.setUp(component, {}); assert.strictEqual('fooValue', component.foo); @@ -78,25 +76,25 @@ describe('ComponentDataManager', function() { component.constructor.STATE = { bar: { internal: true, - value: 'initialBar' + value: 'initialBar', }, foo: { - value: 'initialFoo' + value: 'initialFoo', }, foo2: { - value: 'initialFoo2' - } + value: 'initialFoo2', + }, }; initialConfig = { bar: 'bar', foo: 'foo', - foo2: 'foo2' + foo2: 'foo2', }; ComponentDataManager.setUp(component, {}); ComponentDataManager.replaceNonInternal(component, { - foo: 'newFoo' + foo: 'newFoo', }); assert.strictEqual('newFoo', component.foo); assert.strictEqual('initialFoo2', component.foo2); @@ -105,18 +103,20 @@ describe('ComponentDataManager', function() { it('should return state instance', function() { ComponentDataManager.setUp(component, {}); - assert.ok(ComponentDataManager.getStateInstance(component) instanceof State); + assert.ok( + ComponentDataManager.getStateInstance(component) instanceof State + ); }); it('should return an object with state properties', function() { ComponentDataManager.setUp(component, { foo: { - value: 'fooValue' - } + value: 'fooValue', + }, }); - var expected = { - foo: 'fooValue' + let expected = { + foo: 'fooValue', }; assert.deepEqual(expected, ComponentDataManager.getState(component)); }); @@ -124,8 +124,8 @@ describe('ComponentDataManager', function() { it('should return list of state keys', function() { ComponentDataManager.setUp(component, { foo: { - value: 'fooValue' - } + value: 'fooValue', + }, }); assert.deepEqual(['foo'], ComponentDataManager.getStateKeys(component)); }); @@ -133,8 +133,8 @@ describe('ComponentDataManager', function() { it('should return list of sync keys', function() { ComponentDataManager.setUp(component, { foo: { - value: 'fooValue' - } + value: 'fooValue', + }, }); assert.deepEqual(['foo'], ComponentDataManager.getSyncKeys(component)); }); @@ -142,8 +142,8 @@ describe('ComponentDataManager', function() { it('should get value from state key', function() { ComponentDataManager.setUp(component, { foo: { - value: 'fooValue' - } + value: 'fooValue', + }, }); assert.strictEqual('fooValue', ComponentDataManager.get(component, 'foo')); }); @@ -151,12 +151,12 @@ describe('ComponentDataManager', function() { it('should set value for state key', function() { ComponentDataManager.setUp(component, { foo: { - value: 'fooValue' - } + value: 'fooValue', + }, }); ComponentDataManager.setState(component, { - foo: 'fooValue2' + foo: 'fooValue2', }); assert.strictEqual('fooValue2', component.foo); }); @@ -164,11 +164,11 @@ describe('ComponentDataManager', function() { it('should emit events from state on component', function() { ComponentDataManager.setUp(component, { foo: { - value: 'fooValue' - } + value: 'fooValue', + }, }); - var listener = sinon.stub(); + let listener = sinon.stub(); component.on('fooChanged', listener); component.foo = 'fooValue2'; diff --git a/packages/metal-component/test/ComponentRegistry.js b/packages/metal-component/test/ComponentRegistry.js index b17646e9..b0b1caa4 100644 --- a/packages/metal-component/test/ComponentRegistry.js +++ b/packages/metal-component/test/ComponentRegistry.js @@ -3,7 +3,7 @@ import ComponentRegistry from '../src/ComponentRegistry'; describe('ComponentRegistry', function() { - var originalConsoleFn = console.error; + let originalConsoleFn = console.error; beforeEach(function() { console.error = sinon.stub(); @@ -23,52 +23,60 @@ describe('ComponentRegistry', function() { }); it('should return constructor of registered components', function() { - class MyComponent1 { - } - class MyComponent2 { - } + class MyComponent1 {} + class MyComponent2 {} ComponentRegistry.register(MyComponent1, 'MyComponent1'); ComponentRegistry.register(MyComponent2, 'MyComponent2'); - assert.strictEqual(MyComponent1, ComponentRegistry.getConstructor('MyComponent1')); - assert.strictEqual(MyComponent2, ComponentRegistry.getConstructor('MyComponent2')); + assert.strictEqual( + MyComponent1, + ComponentRegistry.getConstructor('MyComponent1') + ); + assert.strictEqual( + MyComponent2, + ComponentRegistry.getConstructor('MyComponent2') + ); }); it('should set NAME static property of registered components', function() { - class MyComponent { - } + class MyComponent {} ComponentRegistry.register(MyComponent, 'MyName'); assert.strictEqual('MyName', MyComponent.NAME); }); it('should use NAME static property if no name is passed to ComponentRegistry.register', function() { - class MyComponent { - } + class MyComponent {} MyComponent.NAME = 'StaticName'; ComponentRegistry.register(MyComponent); - assert.strictEqual(MyComponent, ComponentRegistry.getConstructor('StaticName')); + assert.strictEqual( + MyComponent, + ComponentRegistry.getConstructor('StaticName') + ); }); it('should use function name if no name is passed to ComponentRegistry.register', function() { - class MyComponent { - } + class MyComponent {} ComponentRegistry.register(MyComponent); assert.strictEqual('MyComponent', MyComponent.NAME); - assert.strictEqual(MyComponent, ComponentRegistry.getConstructor('MyComponent')); + assert.strictEqual( + MyComponent, + ComponentRegistry.getConstructor('MyComponent') + ); }); it('should use function name if NAME is only set on super class and no name is passed to ComponentRegistry.register', function() { - class SuperComponent { - } + class SuperComponent {} SuperComponent.NAME = 'SuperComponent'; - class MyComponent extends SuperComponent { - } + class MyComponent extends SuperComponent {} ComponentRegistry.register(MyComponent); assert.strictEqual('MyComponent', MyComponent.NAME); - assert.strictEqual(MyComponent, ComponentRegistry.getConstructor('MyComponent')); + assert.strictEqual( + MyComponent, + ComponentRegistry.getConstructor('MyComponent') + ); }); }); diff --git a/packages/metal-component/test/ComponentRenderer.js b/packages/metal-component/test/ComponentRenderer.js index e813fb08..06832bb6 100644 --- a/packages/metal-component/test/ComponentRenderer.js +++ b/packages/metal-component/test/ComponentRenderer.js @@ -1,6 +1,6 @@ 'use strict'; -import { isElement, isFunction } from 'metal'; +import {isElement, isFunction} from 'metal'; import ComponentRenderer from '../src/ComponentRenderer'; describe('ComponentRenderer', function() { @@ -8,7 +8,7 @@ describe('ComponentRenderer', function() { beforeEach(function() { componentStub = { - informRendered: sinon.stub() + informRendered: sinon.stub(), }; }); @@ -24,7 +24,10 @@ describe('ComponentRenderer', function() { }); it('should return nothing by default from getExtraDataConfig', function() { - assert.equal(undefined, ComponentRenderer.getExtraDataConfig(componentStub)); + assert.equal( + undefined, + ComponentRenderer.getExtraDataConfig(componentStub) + ); }); it('should have a function called "update"', function() { diff --git a/packages/metal-component/test/events/events.js b/packages/metal-component/test/events/events.js index b0d85e81..ff10e7cc 100644 --- a/packages/metal-component/test/events/events.js +++ b/packages/metal-component/test/events/events.js @@ -1,7 +1,7 @@ 'use strict'; -import { addListenersFromObj, getComponentFn } from '../../src/events/events'; -import { append, triggerEvent } from 'metal-dom'; +import {addListenersFromObj, getComponentFn} from '../../src/events/events'; +import {append, triggerEvent} from 'metal-dom'; import Component from '../../src/Component'; describe('events', function() { @@ -22,13 +22,13 @@ describe('events', function() { describe('addListenersFromObj', function() { it('should attach events to specified functions', function() { - var listener1 = sinon.stub(); - var listener2 = sinon.stub(); + let listener1 = sinon.stub(); + let listener2 = sinon.stub(); comp = new Component(); addListenersFromObj(comp, { event1: listener1, - event2: listener2 + event2: listener2, }); comp.emit('event1'); @@ -41,13 +41,12 @@ describe('events', function() { }); it('should attach events to specified function names', function() { - class CustomComponent extends Component { - } + class CustomComponent extends Component {} CustomComponent.prototype.listener = sinon.stub(); comp = new CustomComponent(); addListenersFromObj(comp, { - event1: 'listener' + event1: 'listener', }); comp.emit('event1'); @@ -57,15 +56,14 @@ describe('events', function() { it('should warn if trying to attach event to unexisting function name', function() { comp = new Component(); addListenersFromObj(comp, { - event1: 'listener' + event1: 'listener', }); assert.strictEqual(1, console.error.callCount); }); it('should attach delegate events with specified selector', function() { - class CustomComponent extends Component { - } + class CustomComponent extends Component {} CustomComponent.prototype.listener = sinon.stub(); comp = new CustomComponent(); @@ -73,8 +71,8 @@ describe('events', function() { addListenersFromObj(comp, { click: { fn: 'listener', - selector: '.testButton' - } + selector: '.testButton', + }, }); triggerEvent(comp.element, 'click'); diff --git a/packages/metal-component/test/sync/sync.js b/packages/metal-component/test/sync/sync.js index 34319012..2b81f8c4 100644 --- a/packages/metal-component/test/sync/sync.js +++ b/packages/metal-component/test/sync/sync.js @@ -1,7 +1,7 @@ 'use strict'; import Component from '../../src/Component'; -import { syncState } from '../../src/sync/sync'; +import {syncState} from '../../src/sync/sync'; describe('sync', function() { let comp; @@ -13,15 +13,14 @@ describe('sync', function() { }); it('should call all "sync" methods on component', function() { - class TestComponent extends Component { - } + class TestComponent extends Component {} TestComponent.STATE = { bar: { - value: 'bar' + value: 'bar', }, foo: { - value: 'foo' - } + value: 'foo', + }, }; TestComponent.prototype.syncBar = sinon.stub(); TestComponent.prototype.syncFoo = sinon.stub(); @@ -37,15 +36,14 @@ describe('sync', function() { }); it('should call "sync" method for properties defined in changes object', function() { - class TestComponent extends Component { - } + class TestComponent extends Component {} TestComponent.STATE = { bar: { - value: 'bar' + value: 'bar', }, foo: { - value: 'foo' - } + value: 'foo', + }, }; TestComponent.prototype.syncBar = sinon.stub(); TestComponent.prototype.syncFoo = sinon.stub(); @@ -54,8 +52,8 @@ describe('sync', function() { syncState(comp, { foo: { newVal: 'newFoo', - prevVal: 'prevFoo' - } + prevVal: 'prevFoo', + }, }); assert.equal(0, comp.syncBar.callCount); assert.equal(1, comp.syncFoo.callCount); @@ -71,8 +69,8 @@ describe('sync', function() { } TestComponent.STATE = { foo: { - value: 'foo' - } + value: 'foo', + }, }; comp = new TestComponent({}, false); diff --git a/packages/metal-dom/package-lock.json b/packages/metal-dom/package-lock.json index f9c637f5..7e4c66d6 100644 --- a/packages/metal-dom/package-lock.json +++ b/packages/metal-dom/package-lock.json @@ -64,7 +64,7 @@ "lodash": "4.17.4", "minimatch": "3.0.4", "path-is-absolute": "1.0.1", - "private": "0.1.7", + "private": "0.1.8", "slash": "1.0.0", "source-map": "0.5.7" } @@ -507,9 +507,9 @@ } }, "babel-preset-env": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/babel-preset-env/-/babel-preset-env-1.6.0.tgz", - "integrity": "sha512-OVgtQRuOZKckrILgMA5rvctvFZPv72Gua9Rt006AiPoB0DJKGN07UmaQA+qRrYgK71MVct8fFhT0EyNWYorVew==", + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/babel-preset-env/-/babel-preset-env-1.6.1.tgz", + "integrity": "sha512-W6VIyA6Ch9ePMI7VptNn2wBM6dbG0eSz25HEiL40nQXCsXGTGZSTZu1Iap+cj3Q0S5a7T9+529l/5Bkvd+afNA==", "requires": { "babel-plugin-check-es2015-constants": "6.22.0", "babel-plugin-syntax-trailing-function-commas": "6.22.0", @@ -538,7 +538,7 @@ "babel-plugin-transform-es2015-unicode-regex": "6.24.1", "babel-plugin-transform-exponentiation-operator": "6.24.1", "babel-plugin-transform-regenerator": "6.26.0", - "browserslist": "2.5.1", + "browserslist": "2.8.0", "invariant": "2.2.2", "semver": "5.4.1" } @@ -625,18 +625,18 @@ } }, "browserslist": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-2.5.1.tgz", - "integrity": "sha512-jAvM2ku7YDJ+leAq3bFH1DE0Ylw+F+EQDq4GkqZfgPEqpWYw9ofQH85uKSB9r3Tv7XDbfqVtE+sdvKJW7IlPJA==", + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-2.8.0.tgz", + "integrity": "sha512-iiWHM1Et6Q4TQpB7Ar6pxuM3TNMXasVJY4Y/oh3q38EwR3Z+IdZ9MyVf7PI4MJFB4xpwMcZgs9bEUnPG2E3TCA==", "requires": { - "caniuse-lite": "1.0.30000746", - "electron-to-chromium": "1.3.25" + "caniuse-lite": "1.0.30000760", + "electron-to-chromium": "1.3.27" } }, "caniuse-lite": { - "version": "1.0.30000746", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000746.tgz", - "integrity": "sha1-xk+Vo5Jc/TAgejCO12wa6W6gnqA=" + "version": "1.0.30000760", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000760.tgz", + "integrity": "sha1-7HIDlXQvHH7IlH/W3SYE53qPmP8=" }, "chalk": { "version": "1.1.3", @@ -687,9 +687,9 @@ } }, "electron-to-chromium": { - "version": "1.3.25", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.25.tgz", - "integrity": "sha1-RTshAJg20Jl9hgNWAf9srkeRxGA=" + "version": "1.3.27", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.27.tgz", + "integrity": "sha1-eOy4o5kGYYe7N07t412ccFZagD0=" }, "escape-string-regexp": { "version": "1.0.5", @@ -879,9 +879,9 @@ "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" }, "private": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/private/-/private-0.1.7.tgz", - "integrity": "sha1-aM5eih7woju1cMwoU3tTMqumPvE=" + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/private/-/private-0.1.8.tgz", + "integrity": "sha512-VvivMrbvd2nKkiG38qjULzlc+4Vx4wm/whI9pQD35YrARNnhxeiRktSOhSukRLFNlzg6Br/cJPet5J/u19r/mg==" }, "regenerate": { "version": "1.3.3", @@ -900,7 +900,7 @@ "requires": { "babel-runtime": "6.26.0", "babel-types": "6.26.0", - "private": "0.1.7" + "private": "0.1.8" } }, "regexpu-core": { diff --git a/packages/metal-dom/src/DomDelegatedEventHandle.js b/packages/metal-dom/src/DomDelegatedEventHandle.js index 563e8fde..b95fb22e 100644 --- a/packages/metal-dom/src/DomDelegatedEventHandle.js +++ b/packages/metal-dom/src/DomDelegatedEventHandle.js @@ -1,8 +1,8 @@ 'use strict'; -import { array, isString } from 'metal'; +import {array, isString} from 'metal'; import domData from './domData'; -import { EventHandle } from 'metal-events'; +import {EventHandle} from 'metal-events'; /** * This is a special EventHandle, that is responsible for dom delegated events @@ -15,13 +15,13 @@ class DomDelegatedEventHandle extends EventHandle { * @param {!Event} emitter Element the event was subscribed to. * @param {string} event The name of the event that was subscribed to. * @param {!Function} listener The listener subscribed to the event. - * @param {string=} opt_selector An optional selector used when delegating + * @param {string=} selector An optional selector used when delegating * the event. * @constructor */ - constructor(emitter, event, listener, opt_selector) { + constructor(emitter, event, listener, selector) { super(emitter, event, listener); - this.selector_ = opt_selector; + this.selector_ = selector; } /** @@ -31,7 +31,9 @@ class DomDelegatedEventHandle extends EventHandle { const delegating = domData.get(this.emitter_, 'delegating', {}); const listeners = domData.get(this.emitter_, 'listeners', {}); const selector = this.selector_; - const arr = isString(selector) ? delegating[this.event_].selectors : listeners; + const arr = isString(selector) + ? delegating[this.event_].selectors + : listeners; const key = isString(selector) ? selector : this.event_; array.remove(arr[key] || [], this.listener_); diff --git a/packages/metal-dom/src/DomEventEmitterProxy.js b/packages/metal-dom/src/DomEventEmitterProxy.js index 3fd44e9c..308cb8b5 100644 --- a/packages/metal-dom/src/DomEventEmitterProxy.js +++ b/packages/metal-dom/src/DomEventEmitterProxy.js @@ -1,7 +1,7 @@ 'use strict'; -import { delegate, on, supportsEvent } from './dom'; -import { EventEmitterProxy } from 'metal-events'; +import {delegate, on, supportsEvent} from './dom'; +import {EventEmitterProxy} from 'metal-events'; /** * DomEventEmitterProxy utility. It extends `EventEmitterProxy` to also accept @@ -23,7 +23,7 @@ class DomEventEmitterProxy extends EventEmitterProxy { const index = event.indexOf(':', 9); const eventName = event.substring(9, index); const selector = event.substring(index + 1); - return delegate(this.originEmitter_, eventName, selector, listener); + return delegate(this.originEmitter_, eventName, selector, listener); // eslint-disable-line } else { return on(this.originEmitter_, event, listener); } @@ -46,13 +46,16 @@ class DomEventEmitterProxy extends EventEmitterProxy { * Checks if the given event is supported by the origin element. * @param {string} event * @protected + * @return {boolean} */ isSupportedDomEvent_(event) { if (!this.originEmitter_ || !this.originEmitter_.addEventListener) { return true; } - return (this.isDelegateEvent_(event) && event.indexOf(':', 9) !== -1) || - supportsEvent(this.originEmitter_, event); + return ( + (this.isDelegateEvent_(event) && event.indexOf(':', 9) !== -1) || + supportsEvent(this.originEmitter_, event) + ); } /** @@ -63,7 +66,7 @@ class DomEventEmitterProxy extends EventEmitterProxy { * @override */ shouldProxyEvent_(event) { - return super.shouldProxyEvent_(event) && this.isSupportedDomEvent_(event); + return super.shouldProxyEvent_(event) && this.isSupportedDomEvent_(event); // eslint-disable-line } } diff --git a/packages/metal-dom/src/DomEventHandle.js b/packages/metal-dom/src/DomEventHandle.js index 6bc26939..7a7da2a7 100644 --- a/packages/metal-dom/src/DomEventHandle.js +++ b/packages/metal-dom/src/DomEventHandle.js @@ -1,6 +1,6 @@ 'use strict'; -import { EventHandle } from 'metal-events'; +import {EventHandle} from 'metal-events'; /** * This is a special EventHandle, that is responsible for dom events, instead @@ -13,20 +13,24 @@ class DomEventHandle extends EventHandle { * @param {!EventEmitter} emitter Emitter the event was subscribed to. * @param {string} event The name of the event that was subscribed to. * @param {!Function} listener The listener subscribed to the event. - * @param {boolean} opt_capture Flag indicating if listener should be triggered + * @param {boolean} capture Flag indicating if listener should be triggered * during capture phase, instead of during the bubbling phase. Defaults to false. * @constructor */ - constructor(emitter, event, listener, opt_capture) { + constructor(emitter, event, listener, capture) { super(emitter, event, listener); - this.capture_ = opt_capture; + this.capture_ = capture; } /** * @inheritDoc */ removeListener() { - this.emitter_.removeEventListener(this.event_, this.listener_, this.capture_); + this.emitter_.removeEventListener( + this.event_, + this.listener_, + this.capture_ + ); } } diff --git a/packages/metal-dom/src/all/dom.js b/packages/metal-dom/src/all/dom.js index d6c6728f..bb3dd17e 100644 --- a/packages/metal-dom/src/all/dom.js +++ b/packages/metal-dom/src/all/dom.js @@ -10,5 +10,12 @@ import globalEvalStyles from '../globalEvalStyles'; import '../events'; export * from '../dom'; -export { domData, DomEventEmitterProxy, DomEventHandle, features, globalEval, globalEvalStyles }; +export { + domData, + DomEventEmitterProxy, + DomEventHandle, + features, + globalEval, + globalEvalStyles, +}; export default dom; diff --git a/packages/metal-dom/src/dom.js b/packages/metal-dom/src/dom.js index a16e4d21..b8949917 100644 --- a/packages/metal-dom/src/dom.js +++ b/packages/metal-dom/src/dom.js @@ -7,5 +7,5 @@ import * as dom from './domNamed'; export default dom; -export { dom }; +export {dom}; export * from './domNamed'; diff --git a/packages/metal-dom/src/domData.js b/packages/metal-dom/src/domData.js index 34f2df43..f2cac29e 100644 --- a/packages/metal-dom/src/domData.js +++ b/packages/metal-dom/src/domData.js @@ -2,26 +2,29 @@ const METAL_DATA = '__metal_data__'; +/** + * Set of utilities for dom data operations + */ class domData { /** * Gets Metal.js's data for the given element. * @param {!Element} element - * @param {string=} opt_name Optional property from the data to be returned. - * @param {*} opt_initialVal Optinal value to the set the requested property + * @param {string=} name Optional property from the data to be returned. + * @param {*=} initialValue Optional value to the set the requested property * to if it doesn't exist yet in the data. * @return {!Object} */ - static get(element, opt_name, opt_initialVal) { + static get(element, name, initialValue) { if (!element[METAL_DATA]) { element[METAL_DATA] = {}; } - if (!opt_name) { + if (!name) { return element[METAL_DATA]; } - if (!element[METAL_DATA][opt_name] && opt_initialVal) { - element[METAL_DATA][opt_name] = opt_initialVal; + if (!element[METAL_DATA][name] && initialValue) { + element[METAL_DATA][name] = initialValue; } - return element[METAL_DATA][opt_name]; + return element[METAL_DATA][name]; } /** diff --git a/packages/metal-dom/src/domNamed.js b/packages/metal-dom/src/domNamed.js index 5e79d686..4e10534b 100644 --- a/packages/metal-dom/src/domNamed.js +++ b/packages/metal-dom/src/domNamed.js @@ -1,6 +1,15 @@ 'use strict'; -import { isDef, isDefAndNotNull, isDocument, isDocumentFragment, isElement, isObject, isString, object } from 'metal'; +import { + isDef, + isDefAndNotNull, + isDocument, + isDocumentFragment, + isElement, + isObject, + isString, + object, +} from 'metal'; import domData from './domData'; import DomDelegatedEventHandle from './DomDelegatedEventHandle'; import DomEventHandle from './DomEventHandle'; @@ -16,7 +25,7 @@ const USE_CAPTURE = { focus: true, invalid: true, load: true, - scroll: true + scroll: true, }; /** @@ -137,7 +146,7 @@ function attachDelegateEvent_(element, eventName) { handleDelegateEvent_, !!USE_CAPTURE[eventName] ), - selectors: {} + selectors: {}, }; } } @@ -221,20 +230,26 @@ export function contains(element1, element2) { * that should match the event for the listener to be triggered. * @param {!function(!Object)} callback Function to be called when the event * is triggered. It will receive the normalized event object. - * @param {boolean=} opt_default Optional flag indicating if this is a default + * @param {boolean=} defaultListener Optional flag indicating if this is a default * listener. That means that it would only be executed after all non * default listeners, and only if the event isn't prevented via * `preventDefault`. * @return {!EventHandle} Can be used to remove the listener. */ -export function delegate(element, eventName, selectorOrTarget, callback, opt_default) { +export function delegate( + element, + eventName, + selectorOrTarget, + callback, + defaultListener +) { const customConfig = customEvents[eventName]; if (customConfig && customConfig.delegate) { eventName = customConfig.originalEvent; callback = customConfig.handler.bind(customConfig, callback); } - if (opt_default) { + if (defaultListener) { // Wrap callback so we don't set property directly on it. callback = callback.bind(); callback.defaultListener_ = true; @@ -260,10 +275,12 @@ export function delegate(element, eventName, selectorOrTarget, callback, opt_def * simulating browsers behaviour, avoiding event listeners to be called by triggerEvent method. * @param {Element} node Element to be checked. * @param {string} eventName The event name. + * @param {Object=} eventObj * @private + * @return {boolean} */ -function isAbleToInteractWith_(node, eventName, opt_eventObj) { - if (opt_eventObj && eventName === 'click' && opt_eventObj.button === 2) { +function isAbleToInteractWith_(node, eventName, eventObj) { + if (eventObj && eventName === 'click' && eventObj.button === 2) { // Firefox triggers "click" events on the document for right clicks. This // causes our delegate logic to trigger it for regular elements too, which // shouldn't happen. Ignoring them here. @@ -283,8 +300,11 @@ function isAbleToInteractWith_(node, eventName, opt_eventObj) { * @return {boolean} Whether variable is like a NodeList. */ export function isNodeListLike(val) { - return isDefAndNotNull(val) && typeof val.length === 'number' && - typeof val.item === 'function'; + return ( + isDefAndNotNull(val) && + typeof val.length === 'number' && + typeof val.item === 'function' + ); } /** @@ -350,8 +370,7 @@ export function hasClass(element, className) { * @private */ function hasClassWithNative_(element, className) { - return className.indexOf(' ') === -1 && - element.classList.contains(className); + return className.indexOf(' ') === -1 && element.classList.contains(className); } /** @@ -362,8 +381,10 @@ function hasClassWithNative_(element, className) { * @private */ function hasClassWithoutNative_(element, className) { - return (` ${element.className} `).indexOf(` ${className} `) >= 0 && - className.split(' ').length === 1; + return ( + ` ${element.className} `.indexOf(` ${className} `) >= 0 && + className.split(' ').length === 1 + ); } /** @@ -387,7 +408,12 @@ export function match(element, selector) { } const p = Element.prototype; - const m = p.matches || p.webkitMatchesSelector || p.mozMatchesSelector || p.msMatchesSelector || p.oMatchesSelector; + const m = + p.matches || + p.webkitMatchesSelector || + p.mozMatchesSelector || + p.msMatchesSelector || + p.oMatchesSelector; if (m) { return m.call(element, selector); } @@ -418,6 +444,7 @@ function matchFallback_(element, selector) { * selector, or null if there is none. * @param {!Element} element * @param {?string} selector + * @return {Element|null} */ export function next(element, selector) { do { @@ -448,11 +475,11 @@ function normalizeDelegateEvent_(event) { * @param {string} eventName The name of the event to listen to. * @param {!function(!Object)} callback Function to be called when the event is * triggered. It will receive the normalized event object. - * @param {boolean} opt_capture Flag indicating if listener should be triggered + * @param {boolean} capture Flag indicating if listener should be triggered * during capture phase, instead of during the bubbling phase. Defaults to false. * @return {!DomEventHandle} Can be used to remove the listener. */ -export function on(element, eventName, callback, opt_capture) { +export function on(element, eventName, callback, capture) { if (isString(element)) { return delegate(document, eventName, element, callback); } @@ -461,8 +488,8 @@ export function on(element, eventName, callback, opt_capture) { eventName = customConfig.originalEvent; callback = customConfig.handler.bind(customConfig, callback); } - element.addEventListener(eventName, callback, opt_capture); - return new DomEventHandle(element, eventName, callback, opt_capture); + element.addEventListener(eventName, callback, capture); + return new DomEventHandle(element, eventName, callback, capture); } /** @@ -478,7 +505,7 @@ export function on(element, eventName, callback, opt_capture) { export function once(element, eventName, callback) { const domEventHandle = on(element, eventName, function() { domEventHandle.removeListener(); - return callback.apply(this, arguments); + return callback.apply(this, arguments); // eslint-disable-line }); return domEventHandle; } @@ -631,7 +658,7 @@ export function supportsEvent(element, eventName) { /** * This triggers all default matched delegated listeners of a given event type. - * @param {!Array} defaultFns Array to collect default listeners in, instead + * @param {!Array} defFns Array to collect default listeners in, instead * @param {!Event} event * @return {boolean} False if at least one of the triggered callbacks returns * false, or true otherwise. @@ -668,7 +695,12 @@ function triggerDelegatedListeners_(container, event, defaultFns) { if (isAbleToInteractWith_(currElement, event.type, event)) { event.delegateTarget = currElement; ret &= triggerElementListeners_(currElement, event, defaultFns); - ret &= triggerSelectorListeners_(container, currElement, event, defaultFns); + ret &= triggerSelectorListeners_( + container, + currElement, + event, + defaultFns + ); } currElement = currElement.parentNode; } @@ -684,7 +716,11 @@ function triggerDelegatedListeners_(container, event, defaultFns) { * @return {Element} The converted element, or null if none was found. */ export function toElement(selectorOrElement) { - if (isElement(selectorOrElement) || isDocument(selectorOrElement) || isDocumentFragment(selectorOrElement)) { + if ( + isElement(selectorOrElement) || + isDocument(selectorOrElement) || + isDocumentFragment(selectorOrElement) + ) { return selectorOrElement; } else if (isString(selectorOrElement)) { if (selectorOrElement[0] === '#' && selectorOrElement.indexOf(' ') === -1) { @@ -750,7 +786,7 @@ function toggleClassesWithoutNative_(element, classes) { elementClassName = `${elementClassName}${classes[i]} `; } else { const before = elementClassName.substring(0, classIndex); - const after = elementClassName.substring(classIndex + className.length); + const after = elementClassName.substring(classIndex + className.length); // eslint-disable-line elementClassName = `${before} ${after}`; } } @@ -783,15 +819,15 @@ function triggerElementListeners_(element, event, defaultFns) { * NOTE: This should mostly be used for testing, not on real code. * @param {!Element} element The node that should trigger the event. * @param {string} eventName The name of the event to be triggred. - * @param {Object=} opt_eventObj An object with data that should be on the + * @param {Object=} eventObj An object with data that should be on the * triggered event's payload. */ -export function triggerEvent(element, eventName, opt_eventObj) { - if (isAbleToInteractWith_(element, eventName, opt_eventObj)) { - const eventObj = document.createEvent('HTMLEvents'); - eventObj.initEvent(eventName, true, true); - object.mixin(eventObj, opt_eventObj); - element.dispatchEvent(eventObj); +export function triggerEvent(element, eventName, eventObj) { + if (isAbleToInteractWith_(element, eventName, eventObj)) { + const payload = document.createEvent('HTMLEvents'); + payload.initEvent(eventName, true, true); + object.mixin(payload, eventObj); + element.dispatchEvent(payload); } } @@ -813,7 +849,7 @@ function triggerListeners_(listeners, event, element, defaultFns) { if (listeners[i].defaultListener_) { defaultFns.push({ element, - fn: listeners[i] + fn: listeners[i], }); } else { ret &= listeners[i](event); diff --git a/packages/metal-dom/src/events.js b/packages/metal-dom/src/events.js index 7d9cb148..b3c97705 100644 --- a/packages/metal-dom/src/events.js +++ b/packages/metal-dom/src/events.js @@ -1,7 +1,7 @@ 'use strict'; -import { isServerSide } from 'metal'; -import { registerCustomEvent, contains } from './dom'; +import {isServerSide} from 'metal'; +import {registerCustomEvent, contains} from './dom'; import features from './features'; /** @@ -12,7 +12,7 @@ function registerEvents() { mouseenter: 'mouseover', mouseleave: 'mouseout', pointerenter: 'pointerover', - pointerleave: 'pointerout' + pointerleave: 'pointerout', }; Object.keys(mouseEventMap).forEach(function(eventName) { registerCustomEvent(eventName, { @@ -20,18 +20,19 @@ function registerEvents() { handler: function(callback, event) { const related = event.relatedTarget; const target = event.delegateTarget; + // eslint-disable-next-line if (!related || (related !== target && !contains(target, related))) { event.customType = eventName; return callback(event); } }, - originalEvent: mouseEventMap[eventName] + originalEvent: mouseEventMap[eventName], }); }); const animationEventMap = { animation: 'animationend', - transition: 'transitionend' + transition: 'transitionend', }; Object.keys(animationEventMap).forEach(function(eventType) { const eventName = animationEventMap[eventType]; @@ -42,7 +43,7 @@ function registerEvents() { event.customType = eventName; return callback(event); }, - originalEvent: features.checkAnimationEventName()[eventType] + originalEvent: features.checkAnimationEventName()[eventType], }); }); } diff --git a/packages/metal-dom/src/features.js b/packages/metal-dom/src/features.js index 75f5c2ee..35781545 100644 --- a/packages/metal-dom/src/features.js +++ b/packages/metal-dom/src/features.js @@ -1,7 +1,7 @@ 'use strict'; -import { append } from './dom'; -import { string } from 'metal'; +import {append} from './dom'; +import {string} from 'metal'; /** * Class with static methods responsible for doing browser feature checks. @@ -17,7 +17,7 @@ class features { if (features.animationEventName_ === undefined) { features.animationEventName_ = { animation: features.checkAnimationEventName_('animation'), - transition: features.checkAnimationEventName_('transition') + transition: features.checkAnimationEventName_('transition'), }; } return features.animationEventName_; @@ -30,13 +30,26 @@ class features { */ static checkAnimationEventName_(type) { const prefixes = ['Webkit', 'MS', 'O', '']; - const typeTitleCase = string.replaceInterval(type, 0, 1, type.substring(0, 1).toUpperCase()); - const suffixes = [`${typeTitleCase}End`, `${typeTitleCase}End`, `${typeTitleCase}End`, `${type}end`]; + const typeTitleCase = string.replaceInterval( + type, + 0, + 1, + type.substring(0, 1).toUpperCase() + ); + const suffixes = [ + `${typeTitleCase}End`, + `${typeTitleCase}End`, + `${typeTitleCase}End`, + `${type}end`, + ]; if (!features.animationElement_) { features.animationElement_ = document.createElement('div'); } for (let i = 0; i < prefixes.length; i++) { - if (features.animationElement_.style[prefixes[i] + typeTitleCase] !== undefined) { + if ( + features.animationElement_.style[prefixes[i] + typeTitleCase] !== // eslint-disable-line + undefined + ) { return prefixes[i].toLowerCase() + suffixes[i]; } } diff --git a/packages/metal-dom/src/globalEval.js b/packages/metal-dom/src/globalEval.js index 7c275515..d186049f 100644 --- a/packages/metal-dom/src/globalEval.js +++ b/packages/metal-dom/src/globalEval.js @@ -1,7 +1,7 @@ 'use strict'; -import { async } from 'metal'; -import { exitDocument, once } from './dom'; +import {async} from 'metal'; +import {exitDocument, once} from './dom'; /** * Utility functions for running javascript code in the global scope. @@ -10,15 +10,15 @@ class globalEval { /** * Evaluates the given string in the global scope. * @param {string} text - * @param {function()=} opt_appendFn Optional function to append the node + * @param {function()=} appendFn Optional function to append the node * into document. * @return {Element} script */ - static run(text, opt_appendFn) { + static run(text, appendFn) { const script = document.createElement('script'); script.text = text; - if (opt_appendFn) { - opt_appendFn(script); + if (appendFn) { + appendFn(script); } else { document.head.appendChild(script); } @@ -29,25 +29,25 @@ class globalEval { /** * Evaluates the given javascript file in the global scope. * @param {string} src The file's path. - * @param {function()=} opt_callback Optional function to be called + * @param {function()=} defaultFn Optional function to be called * when the script has been run. - * @param {function()=} opt_appendFn Optional function to append the node + * @param {function()=} appendFn Optional function to append the node * into document. * @return {Element} script */ - static runFile(src, opt_callback, opt_appendFn) { + static runFile(src, defaultFn, appendFn) { const script = document.createElement('script'); script.src = src; const callback = function() { exitDocument(script); - opt_callback && opt_callback(); + defaultFn && defaultFn(); }; once(script, 'load', callback); once(script, 'error', callback); - if (opt_appendFn) { - opt_appendFn(script); + if (appendFn) { + appendFn(script); } else { document.head.appendChild(script); } @@ -58,15 +58,15 @@ class globalEval { /** * Evaluates the code referenced by the given script element. * @param {!Element} script - * @param {function()=} opt_callback Optional function to be called + * @param {function()=} defaultFn Optional function to be called * when the script has been run. - * @param {function()=} opt_appendFn Optional function to append the node + * @param {function()=} appendFn Optional function to append the node * into document. * @return {Element} script */ - static runScript(script, opt_callback, opt_appendFn) { + static runScript(script, defaultFn, appendFn) { const callback = function() { - opt_callback && opt_callback(); + defaultFn && defaultFn(); }; if (script.type && script.type !== 'text/javascript') { async.nextTick(callback); @@ -74,27 +74,27 @@ class globalEval { } exitDocument(script); if (script.src) { - return globalEval.runFile(script.src, opt_callback, opt_appendFn); + return globalEval.runFile(script.src, defaultFn, appendFn); } else { async.nextTick(callback); - return globalEval.run(script.text, opt_appendFn); + return globalEval.run(script.text, appendFn); } } /** * Evaluates any script tags present in the given element. * @param {!Element} element - * @param {function()=} opt_callback Optional function to be called + * @param {function()=} defaultFn Optional function to be called * when the script has been run. - * @param {function()=} opt_appendFn Optional function to append the node + * @param {function()=} appendFn Optional function to append the node * into document. */ - static runScriptsInElement(element, opt_callback, opt_appendFn) { + static runScriptsInElement(element, defaultFn, appendFn) { const scripts = element.querySelectorAll('script'); if (scripts.length) { - globalEval.runScriptsInOrder(scripts, 0, opt_callback, opt_appendFn); - } else if (opt_callback) { - async.nextTick(opt_callback); + globalEval.runScriptsInOrder(scripts, 0, defaultFn, appendFn); + } else if (defaultFn) { + async.nextTick(defaultFn); } } @@ -102,19 +102,23 @@ class globalEval { * Runs the given scripts elements in the order that they appear. * @param {!NodeList} scripts * @param {number} index - * @param {function()=} opt_callback Optional function to be called + * @param {function()=} defaultFn Optional function to be called * when the script has been run. - * @param {function()=} opt_appendFn Optional function to append the node + * @param {function()=} appendFn Optional function to append the node * into document. */ - static runScriptsInOrder(scripts, index, opt_callback, opt_appendFn) { - globalEval.runScript(scripts.item(index), function() { - if (index < scripts.length - 1) { - globalEval.runScriptsInOrder(scripts, index + 1, opt_callback, opt_appendFn); - } else if (opt_callback) { - async.nextTick(opt_callback); - } - }, opt_appendFn); + static runScriptsInOrder(scripts, index, defaultFn, appendFn) { + globalEval.runScript( + scripts.item(index), + function() { + if (index < scripts.length - 1) { + globalEval.runScriptsInOrder(scripts, index + 1, defaultFn, appendFn); // eslint-disable-line + } else if (defaultFn) { + async.nextTick(defaultFn); + } + }, + appendFn + ); } } diff --git a/packages/metal-dom/src/globalEvalStyles.js b/packages/metal-dom/src/globalEvalStyles.js index 27d6d902..a4094f46 100644 --- a/packages/metal-dom/src/globalEvalStyles.js +++ b/packages/metal-dom/src/globalEvalStyles.js @@ -1,7 +1,7 @@ 'use strict'; -import { async } from 'metal'; -import { once } from './dom'; +import {async} from 'metal'; +import {once} from './dom'; /** * Utility functions for running styles. @@ -10,15 +10,15 @@ class globalEvalStyles { /** * Evaluates the given style. * @param {string} text - * @param {function()=} opt_appendFn Optional function to append the node + * @param {function()=} appendFn Optional function to append the node * into document. * @return {Element} style */ - static run(text, opt_appendFn) { + static run(text, appendFn) { const style = document.createElement('style'); style.innerHTML = text; - if (opt_appendFn) { - opt_appendFn(style); + if (appendFn) { + appendFn(style); } else { document.head.appendChild(style); } @@ -28,32 +28,32 @@ class globalEvalStyles { /** * Evaluates the given style file. * @param {string} href The file's path. - * @param {function()=} opt_callback Optional function to be called + * @param {function()=} defaultFn Optional function to be called * when the styles has been run. - * @param {function()=} opt_appendFn Optional function to append the node + * @param {function()=} appendFn Optional function to append the node * into document. * @return {Element} style */ - static runFile(href, opt_callback, opt_appendFn) { + static runFile(href, defaultFn, appendFn) { const link = document.createElement('link'); link.rel = 'stylesheet'; link.href = href; - globalEvalStyles.runStyle(link, opt_callback, opt_appendFn); + globalEvalStyles.runStyle(link, defaultFn, appendFn); return link; } /** * Evaluates the code referenced by the given style/link element. * @param {!Element} style - * @param {function()=} opt_callback Optional function to be called + * @param {function()=} defaultFn Optional function to be called * when the script has been run. - * @param {function()=} opt_appendFn Optional function to append the node + * @param {function()=} appendFn Optional function to append the node * into document. * @return {Element} style */ - static runStyle(style, opt_callback, opt_appendFn) { + static runStyle(style, defaultFn, appendFn) { const callback = function() { - opt_callback && opt_callback(); + defaultFn && defaultFn(); }; if (style.rel && style.rel !== 'stylesheet') { async.nextTick(callback); @@ -67,8 +67,8 @@ class globalEvalStyles { once(style, 'error', callback); } - if (opt_appendFn) { - opt_appendFn(style); + if (appendFn) { + appendFn(style); } else { document.head.appendChild(style); } @@ -79,26 +79,26 @@ class globalEvalStyles { /** * Evaluates any style present in the given element. * @param {!Element} element - * @param {function()=} opt_callback Optional function to be called when the + * @param {function()=} defaultFn Optional function to be called when the * style has been run. - * @param {function()=} opt_appendFn Optional function to append the node + * @param {function()=} appendFn Optional function to append the node * into document. */ - static runStylesInElement(element, opt_callback, opt_appendFn) { + static runStylesInElement(element, defaultFn, appendFn) { const styles = element.querySelectorAll('style,link'); - if (styles.length === 0 && opt_callback) { - async.nextTick(opt_callback); + if (styles.length === 0 && defaultFn) { + async.nextTick(defaultFn); return; } let loadCount = 0; const callback = function() { - if (opt_callback && ++loadCount === styles.length) { - async.nextTick(opt_callback); + if (defaultFn && ++loadCount === styles.length) { + async.nextTick(defaultFn); } }; for (let i = 0; i < styles.length; i++) { - globalEvalStyles.runStyle(styles[i], callback, opt_appendFn); + globalEvalStyles.runStyle(styles[i], callback, appendFn); } } } diff --git a/packages/metal-dom/test/.eslintrc b/packages/metal-dom/test/.eslintrc new file mode 100644 index 00000000..790a71ae --- /dev/null +++ b/packages/metal-dom/test/.eslintrc @@ -0,0 +1,16 @@ +{ + "env": { + "mocha": true + }, + "globals": { + "after": true, + "assert": true, + "before": true, + "sinon": true + }, + "rules": { + "max-len": 0, + "no-invalid-this": 0, + "require-jsdoc": 0 + } +} \ No newline at end of file diff --git a/packages/metal-dom/test/DomDelegatedEventHandle.js b/packages/metal-dom/test/DomDelegatedEventHandle.js index 0fe87cd0..32dbfcfc 100644 --- a/packages/metal-dom/test/DomDelegatedEventHandle.js +++ b/packages/metal-dom/test/DomDelegatedEventHandle.js @@ -5,38 +5,30 @@ import DomDelegatedEventHandle from '../src/DomDelegatedEventHandle'; describe('DomDelegatedEventHandle', function() { it('should remove listener from the metal data listeners array', function() { - var element = document.createElement('div'); - var listeners = domData.get(element, 'listeners', {}); - listeners.click = [() => { - }, () => { - }, () => { - }]; - var fn = listeners.click[1]; + let element = document.createElement('div'); + let listeners = domData.get(element, 'listeners', {}); + listeners.click = [() => {}, () => {}, () => {}]; + let fn = listeners.click[1]; - var handle = new DomDelegatedEventHandle(element, 'click', fn); + let handle = new DomDelegatedEventHandle(element, 'click', fn); handle.removeListener(); assert.strictEqual(2, listeners.click.length); assert.strictEqual(-1, listeners.click.indexOf(fn)); }); it('should not throw error if trying to remove unexisting listener', function() { - var element = document.createElement('div'); - var listeners = domData.get(element, 'listeners', {}); - listeners.click = [() => { - }, () => { - }, () => { - }]; + let element = document.createElement('div'); + let listeners = domData.get(element, 'listeners', {}); + listeners.click = [() => {}, () => {}, () => {}]; - var handle = new DomDelegatedEventHandle(element, 'click', () => { - }); + let handle = new DomDelegatedEventHandle(element, 'click', () => {}); handle.removeListener(); assert.strictEqual(3, listeners.click.length); }); it('should not throw error if element has no listeners to be removed', function() { - var element = document.createElement('div'); - var handle = new DomDelegatedEventHandle(element, 'click', () => { - }); + let element = document.createElement('div'); + let handle = new DomDelegatedEventHandle(element, 'click', () => {}); assert.doesNotThrow(() => handle.removeListener()); }); }); diff --git a/packages/metal-dom/test/DomEventEmitterProxy.js b/packages/metal-dom/test/DomEventEmitterProxy.js index 13ea0602..abfe8226 100644 --- a/packages/metal-dom/test/DomEventEmitterProxy.js +++ b/packages/metal-dom/test/DomEventEmitterProxy.js @@ -3,7 +3,7 @@ import dom from '../src/dom'; import features from '../src/features'; import DomEventEmitterProxy from '../src/DomEventEmitterProxy'; -import { EventEmitter } from 'metal-events'; +import {EventEmitter} from 'metal-events'; describe('DomEventEmitterProxy', function() { afterEach(function() { @@ -11,11 +11,11 @@ describe('DomEventEmitterProxy', function() { }); it('should proxy event from event emitter origin to target', function() { - var origin = new EventEmitter(); - var target = new EventEmitter(); + let origin = new EventEmitter(); + let target = new EventEmitter(); new DomEventEmitterProxy(origin, target); - var listener = sinon.stub(); + let listener = sinon.stub(); target.on('event1', listener); origin.emit('event1', 1, 2); @@ -25,13 +25,13 @@ describe('DomEventEmitterProxy', function() { }); it('should proxy event from dom element origin to target', function() { - var origin = document.createElement('div'); + let origin = document.createElement('div'); document.body.appendChild(origin); - var target = new EventEmitter(); + let target = new EventEmitter(); new DomEventEmitterProxy(origin, target); - var listener = sinon.stub(); + let listener = sinon.stub(); target.on('click', listener); dom.triggerEvent(origin, 'click'); @@ -41,13 +41,13 @@ describe('DomEventEmitterProxy', function() { }); it('should proxy custom event from dom element origin to target', function() { - var origin = document.createElement('div'); + let origin = document.createElement('div'); document.body.appendChild(origin); - var target = new EventEmitter(); + let target = new EventEmitter(); new DomEventEmitterProxy(origin, target); - var listener = sinon.stub(); + let listener = sinon.stub(); target.on('transitionend', listener); dom.triggerEvent(origin, features.checkAnimationEventName().transition); @@ -55,10 +55,10 @@ describe('DomEventEmitterProxy', function() { }); it('should not proxy unsupported dom event from dom element', function() { - var origin = document.createElement('div'); + let origin = document.createElement('div'); origin.addEventListener = sinon.stub(); - var target = new EventEmitter(); + let target = new EventEmitter(); new DomEventEmitterProxy(origin, target); target.on('event1', sinon.stub()); @@ -66,10 +66,10 @@ describe('DomEventEmitterProxy', function() { }); it('should proxy event from document to target', function() { - var target = new EventEmitter(); + let target = new EventEmitter(); new DomEventEmitterProxy(document, target); - var listener = sinon.stub(); + let listener = sinon.stub(); target.on('click', listener); dom.triggerEvent(document, 'click'); @@ -77,16 +77,16 @@ describe('DomEventEmitterProxy', function() { }); it('should proxy delegate event from dom element origin to target', function() { - var origin = document.createElement('div'); + let origin = document.createElement('div'); dom.append(origin, ''); document.body.appendChild(origin); - var target = new EventEmitter(); + let target = new EventEmitter(); new DomEventEmitterProxy(origin, target); - var listener = sinon.stub(); + let listener = sinon.stub(); target.on('delegate:click:.testButton', listener); - var button = origin.querySelector('.testButton'); + let button = origin.querySelector('.testButton'); dom.triggerEvent(button, 'click'); assert.strictEqual(1, listener.callCount); @@ -95,16 +95,16 @@ describe('DomEventEmitterProxy', function() { }); it('should proxy delegate event that contains ":" in selector', function() { - var origin = document.createElement('div'); + let origin = document.createElement('div'); dom.append(origin, ''); document.body.appendChild(origin); - var target = new EventEmitter(); + let target = new EventEmitter(); new DomEventEmitterProxy(origin, target); - var listener = sinon.stub(); + let listener = sinon.stub(); target.on('delegate:click:[data-onclick="test:handleClick"]', listener); - var button = origin.querySelector('[data-onclick="test:handleClick"]'); + let button = origin.querySelector('[data-onclick="test:handleClick"]'); dom.triggerEvent(button, 'click'); assert.strictEqual(1, listener.callCount); @@ -112,10 +112,10 @@ describe('DomEventEmitterProxy', function() { }); it('should try to proxy event with "delegate:" prefix but no selector', function() { - var origin = document.createElement('div'); + let origin = document.createElement('div'); document.body.appendChild(origin); - var target = new EventEmitter(); + let target = new EventEmitter(); new DomEventEmitterProxy(origin, target); sinon.spy(dom, 'delegate'); @@ -127,16 +127,16 @@ describe('DomEventEmitterProxy', function() { }); it('should change the element that events are proxied from', function() { - var origin = document.createElement('div'); + let origin = document.createElement('div'); document.body.appendChild(origin); - var target = new EventEmitter(); - var proxy = new DomEventEmitterProxy(origin, target); + let target = new EventEmitter(); + let proxy = new DomEventEmitterProxy(origin, target); - var listener = sinon.stub(); + let listener = sinon.stub(); target.on('click', listener); - var origin2 = document.createElement('div'); + let origin2 = document.createElement('div'); document.body.appendChild(origin2); proxy.setOriginEmitter(origin2); @@ -151,11 +151,11 @@ describe('DomEventEmitterProxy', function() { }); it('should not proxy event emitter events after disposed', function() { - var origin = new EventEmitter(); - var target = new EventEmitter(); - var proxy = new DomEventEmitterProxy(origin, target); + let origin = new EventEmitter(); + let target = new EventEmitter(); + let proxy = new DomEventEmitterProxy(origin, target); - var listener = sinon.stub(); + let listener = sinon.stub(); target.on('event1', listener); proxy.dispose(); @@ -164,12 +164,12 @@ describe('DomEventEmitterProxy', function() { }); it('should not proxy dom events after disposed', function() { - var origin = document.createElement('div'); + let origin = document.createElement('div'); - var target = new EventEmitter(); - var proxy = new DomEventEmitterProxy(origin, target); + let target = new EventEmitter(); + let proxy = new DomEventEmitterProxy(origin, target); - var listener = sinon.stub(); + let listener = sinon.stub(); target.on('click', listener); proxy.dispose(); @@ -178,10 +178,10 @@ describe('DomEventEmitterProxy', function() { }); it('should not throw error if origin emitter is null', function() { - var target = new EventEmitter(); + let target = new EventEmitter(); new DomEventEmitterProxy(null, target); - var listener = sinon.stub(); + let listener = sinon.stub(); assert.doesNotThrow(() => target.on('click', listener)); }); }); diff --git a/packages/metal-dom/test/DomEventHandle.js b/packages/metal-dom/test/DomEventHandle.js index d075dc61..f4ac7577 100644 --- a/packages/metal-dom/test/DomEventHandle.js +++ b/packages/metal-dom/test/DomEventHandle.js @@ -4,11 +4,11 @@ import DomEventHandle from '../src/DomEventHandle'; describe('DomEventHandle', function() { it('should unsubscribe listener', function() { - var element = { - removeEventListener: sinon.stub() + let element = { + removeEventListener: sinon.stub(), }; - var listener = sinon.stub(); - var handle = new DomEventHandle(element, 'event', listener); + let listener = sinon.stub(); + let handle = new DomEventHandle(element, 'event', listener); handle.removeListener(); assert.strictEqual(1, element.removeEventListener.callCount); @@ -17,11 +17,11 @@ describe('DomEventHandle', function() { }); it('should unsubscribe listener attached on capture phase', function() { - var element = { - removeEventListener: sinon.stub() + let element = { + removeEventListener: sinon.stub(), }; - var listener = sinon.stub(); - var handle = new DomEventHandle(element, 'event', listener, true); + let listener = sinon.stub(); + let handle = new DomEventHandle(element, 'event', listener, true); handle.removeListener(); assert.strictEqual(1, element.removeEventListener.callCount); diff --git a/packages/metal-dom/test/dom.js b/packages/metal-dom/test/dom.js index 1700a72a..3d98ae8d 100644 --- a/packages/metal-dom/test/dom.js +++ b/packages/metal-dom/test/dom.js @@ -1,12 +1,11 @@ 'use strict'; import dom from '../src/all/dom'; -import { object } from 'metal'; +import {object} from 'metal'; import UA from 'metal-useragent'; import DomEventHandle from '../src/DomEventHandle'; describe('dom', function() { - afterEach(function() { document.body.innerHTML = ''; }); @@ -19,7 +18,7 @@ describe('dom', function() { assert.strictEqual('class2', getClassNames(element)[1]); } - var element = document.createElement('div'); + const element = document.createElement('div'); dom.addClasses(element, 'class1 class2'); assertClassesAdded(); }); @@ -31,11 +30,11 @@ describe('dom', function() { assert.strictEqual('class2', getClassNames(element)[1]); } - var element1 = document.createElement('div'); - var element2 = document.createElement('div'); + let element1 = document.createElement('div'); + let element2 = document.createElement('div'); dom.append(document.body, element1); dom.append(document.body, element2); - var elements = document.querySelectorAll('div'); + let elements = document.querySelectorAll('div'); dom.addClasses(elements, 'class1 class2'); @@ -44,19 +43,19 @@ describe('dom', function() { }); it('should not throw error if addClasses is called with empty string', function() { - var element = document.createElement('div'); + let element = document.createElement('div'); assert.doesNotThrow(() => dom.addClasses(element, '')); }); it('should not add css classes twice to the same element', function() { - var element = document.createElement('div'); + let element = document.createElement('div'); dom.addClasses(element, 'class1 class2'); dom.addClasses(element, 'class1 class2'); assert.strictEqual('class1 class2', element.className.trim()); }); it('should check if an element has the requested css class', function() { - var element = document.createElement('div'); + let element = document.createElement('div'); dom.addClasses(element, 'class1 class2'); assert.ok(dom.hasClass(element, 'class1')); @@ -67,7 +66,7 @@ describe('dom', function() { }); it('should check if css classes are being removed', function() { - var element = document.createElement('div'); + let element = document.createElement('div'); dom.addClasses(element, 'class1 class2'); dom.removeClasses(element, 'class1'); @@ -81,11 +80,11 @@ describe('dom', function() { assert.ok(dom.hasClass(element, 'class2')); } - var element1 = document.createElement('div'); - var element2 = document.createElement('div'); + let element1 = document.createElement('div'); + let element2 = document.createElement('div'); dom.append(document.body, element1); dom.append(document.body, element2); - var elements = document.querySelectorAll('div'); + let elements = document.querySelectorAll('div'); dom.addClasses(elements, 'class1 class2'); dom.removeClasses(elements, 'class1'); @@ -95,12 +94,12 @@ describe('dom', function() { }); it('should not throw error if removeClasses is called with empty string', function() { - var element = document.createElement('div'); + let element = document.createElement('div'); assert.doesNotThrow(() => dom.removeClasses(element, '')); }); it('should do nothing if element or classes are not object and string in add/remove classes', function() { - var element = document.createElement('div'); + let element = document.createElement('div'); assert.doesNotThrow(function() { dom.addClasses(element); }); @@ -112,7 +111,7 @@ describe('dom', function() { }); it('should do nothing if element or classes are not object and string in toggle classes', function() { - var element = document.createElement('div'); + let element = document.createElement('div'); assert.doesNotThrow(function() { dom.toggleClasses(element); }); @@ -124,7 +123,7 @@ describe('dom', function() { }); it('should toggle classes in an element', function() { - var element = document.createElement('div'); + let element = document.createElement('div'); element.className = 'lorem'; dom.toggleClasses(element, 'lorem'); @@ -144,11 +143,17 @@ describe('dom', function() { element.className = 'lorem ipsum dolor sit amet'; dom.toggleClasses(element, 'lorem sit consectetur adipiscing elit'); - assert.strictEqual('ipsum dolor amet consectetur adipiscing elit', element.className); + assert.strictEqual( + 'ipsum dolor amet consectetur adipiscing elit', + element.className + ); element.className = 'lorem ipsum dolor sit amet'; dom.toggleClasses(element, 'adipiscing elit lorem sit consectetur'); - assert.strictEqual('ipsum dolor amet adipiscing elit consectetur', element.className); + assert.strictEqual( + 'ipsum dolor amet adipiscing elit consectetur', + element.className + ); }); it('should return false when checking if a classname with spaces exists', function() { @@ -164,9 +169,9 @@ describe('dom', function() { describe('contains', function() { it('should check if element contains another', function() { - var element1 = document.createElement('div'); - var element2 = document.createElement('div'); - var element3 = document.createElement('div'); + let element1 = document.createElement('div'); + let element2 = document.createElement('div'); + let element3 = document.createElement('div'); dom.append(element1, element2); dom.enterDocument(element3); @@ -182,8 +187,8 @@ describe('dom', function() { describe('manipulation', function() { it('should append html string to parent element', function() { - var parent = document.createElement('div'); - var childHtml = '
'; + let parent = document.createElement('div'); + let childHtml = '
'; dom.append(parent, childHtml); assert.strictEqual(childHtml, parent.innerHTML); @@ -191,16 +196,18 @@ describe('dom', function() { }); it('should append element to parent element', function() { - var parent = document.createElement('div'); - var child = document.createElement('div'); + let parent = document.createElement('div'); + let child = document.createElement('div'); dom.append(parent, child); assert.strictEqual(parent, child.parentNode); }); it('should append node list to parent element', function() { - var parent = document.createElement('div'); - var childFrag = dom.buildFragment('
'); + let parent = document.createElement('div'); + let childFrag = dom.buildFragment( + '
' + ); dom.append(parent, childFrag.childNodes); assert.strictEqual(2, parent.childNodes.length); @@ -209,8 +216,8 @@ describe('dom', function() { }); it('should replace an element with a requested element', function() { - var element1 = document.createElement('div'); - var element2 = document.createElement('div'); + let element1 = document.createElement('div'); + let element2 = document.createElement('div'); dom.append(document.body, element1); dom.replace(element1, element2); @@ -219,7 +226,7 @@ describe('dom', function() { }); it('should not remove element from parent if replacing it with itself', function() { - var element = document.createElement('div'); + let element = document.createElement('div'); dom.append(document.body, element); dom.replace(element, element); @@ -227,8 +234,8 @@ describe('dom', function() { }); it('should not throw error if trying to replace element that doesn\'t have a parent', function() { - var element1 = document.createElement('div'); - var element2 = document.createElement('div'); + let element1 = document.createElement('div'); + let element2 = document.createElement('div'); assert.doesNotThrow(function() { dom.replace(element1, element2); @@ -236,7 +243,7 @@ describe('dom', function() { }); it('should not throw error if null as passed as one of the elements for "replace"', function() { - var element = document.createElement('div'); + let element = document.createElement('div'); dom.append(document.body, element); assert.doesNotThrow(function() { @@ -254,14 +261,14 @@ describe('dom', function() { assert.ok(!dom.isNodeListLike(function() {})); assert.ok(!dom.isNodeListLike(null)); - var html = '
Hello World 1
Hello World 2
'; - var fragment = dom.buildFragment(html); + let html = '
Hello World 1
Hello World 2
'; + let fragment = dom.buildFragment(html); assert.ok(dom.isNodeListLike(fragment.childNodes)); }); it('should node enter document', function() { - var element = document.createElement('div'); + let element = document.createElement('div'); dom.enterDocument(element); assert.strictEqual(document.body, element.parentNode); }); @@ -273,14 +280,14 @@ describe('dom', function() { }); it('should node exit document', function() { - var element = document.createElement('div'); + let element = document.createElement('div'); dom.enterDocument(element); dom.exitDocument(element); assert.strictEqual(null, element.parentNode); }); it('should not throw error if "exitDocument" is called on element without parent', function() { - var element = document.createElement('div'); + let element = document.createElement('div'); assert.doesNotThrow(function() { dom.exitDocument(element); }); @@ -293,7 +300,7 @@ describe('dom', function() { }); it('should append string as document fragment to parent element', function() { - var parent = document.createElement('div'); + let parent = document.createElement('div'); sinon.stub(parent, 'appendChild'); dom.append(parent, '
'); @@ -305,8 +312,8 @@ describe('dom', function() { }); it('should create document fragment from string', function() { - var html = '
Hello World 1
Hello World 2
'; - var fragment = dom.buildFragment(html); + let html = '
Hello World 1
Hello World 2
'; + let fragment = dom.buildFragment(html); assert.ok(fragment); assert.strictEqual(11, fragment.nodeType); @@ -316,7 +323,7 @@ describe('dom', function() { }); it('should remove children from element', function() { - var element = document.createElement('div'); + let element = document.createElement('div'); element.innerHTML = '
0
1
'; dom.removeChildren(element); @@ -326,8 +333,8 @@ describe('dom', function() { describe('on', function() { it('should listen to event on requested element', function() { - var element = document.createElement('div'); - var listener = sinon.stub(); + let element = document.createElement('div'); + let listener = sinon.stub(); dom.on(element, 'myEvent', listener); assert.strictEqual(0, listener.callCount); @@ -336,10 +343,10 @@ describe('dom', function() { }); it('should be able to remove listener from return value of "on"', function() { - var element = document.createElement('div'); - var listener = sinon.stub(); + let element = document.createElement('div'); + let listener = sinon.stub(); - var handle = dom.on(element, 'myEvent', listener); + let handle = dom.on(element, 'myEvent', listener); assert.ok(handle instanceof DomEventHandle); handle.removeListener(); @@ -348,25 +355,25 @@ describe('dom', function() { }); it('should listen to event on document if selector is passed instead of element', function() { - var element = document.createElement('div'); + let element = document.createElement('div'); element.className = 'myClass'; dom.enterDocument(element); - var listener = sinon.stub(); + let listener = sinon.stub(); dom.on('.myClass', 'click', listener); dom.triggerEvent(element, 'click'); assert.strictEqual(1, listener.callCount); }); it('should listen to event on capture phase', function() { - var element = document.createElement('div'); - var parentElement = document.createElement('div'); + let element = document.createElement('div'); + let parentElement = document.createElement('div'); parentElement.appendChild(element); dom.enterDocument(parentElement); - var listener = sinon.stub(); + let listener = sinon.stub(); dom.on(element, 'click', listener); - var parentListener = sinon.stub(); + let parentListener = sinon.stub(); dom.on(parentElement, 'click', parentListener, true); dom.triggerEvent(element, 'click'); @@ -374,11 +381,11 @@ describe('dom', function() { }); it('should remove listener that was attached on capture phase', function() { - var element = document.createElement('div'); + let element = document.createElement('div'); dom.enterDocument(element); - var listener = sinon.stub(); - var handle = dom.on(element, 'click', listener, true); + let listener = sinon.stub(); + let handle = dom.on(element, 'click', listener, true); handle.removeListener(); dom.triggerEvent(element, 'click'); @@ -388,8 +395,8 @@ describe('dom', function() { describe('once', function() { it('should listen once to event on requested element', function() { - var element = document.createElement('div'); - var listener = sinon.stub(); + let element = document.createElement('div'); + let listener = sinon.stub(); dom.once(element, 'myEvent', listener); assert.strictEqual(0, listener.callCount); @@ -399,10 +406,10 @@ describe('dom', function() { }); it('should be able to remove listener from return value of "once"', function() { - var element = document.createElement('div'); - var listener = sinon.stub(); + let element = document.createElement('div'); + let listener = sinon.stub(); - var handle = dom.once(element, 'myEvent', listener); + let handle = dom.once(element, 'myEvent', listener); assert.ok(handle instanceof DomEventHandle); handle.removeListener(); @@ -413,8 +420,8 @@ describe('dom', function() { describe('triggerEvent', function() { it('should trigger dom event', function() { - var listener = sinon.stub(); - var element = document.createElement('div'); + let listener = sinon.stub(); + let element = document.createElement('div'); document.body.appendChild(element); element.addEventListener('click', listener); @@ -425,13 +432,13 @@ describe('dom', function() { }); it('should add specified payload keys to triggered event', function() { - var listener = sinon.stub(); - var element = document.createElement('div'); + let listener = sinon.stub(); + let element = document.createElement('div'); document.body.appendChild(element); element.addEventListener('click', listener); dom.triggerEvent(element, 'click', { - test: 'test' + test: 'test', }); assert.strictEqual(1, listener.callCount); assert.strictEqual('click', listener.args[0][0].type); @@ -440,10 +447,10 @@ describe('dom', function() { }); it('should not trigger dom click event for disabled elements', function() { - var input = document.createElement('input'); - var select = document.createElement('select'); - var button = document.createElement('button'); - var textarea = document.createElement('textarea'); + let input = document.createElement('input'); + let select = document.createElement('select'); + let button = document.createElement('button'); + let textarea = document.createElement('textarea'); input.disabled = true; select.disabled = true; button.disabled = true; @@ -453,10 +460,10 @@ describe('dom', function() { document.body.appendChild(button); document.body.appendChild(textarea); - var listener1 = sinon.stub(); - var listener2 = sinon.stub(); - var listener3 = sinon.stub(); - var listener4 = sinon.stub(); + let listener1 = sinon.stub(); + let listener2 = sinon.stub(); + let listener3 = sinon.stub(); + let listener4 = sinon.stub(); input.addEventListener('click', listener1); select.addEventListener('click', listener2); @@ -474,23 +481,23 @@ describe('dom', function() { }); it('should not trigger dom click event on a form control with a disabled fieldset parent', function() { - var parent = document.createElement('fieldset'); + let parent = document.createElement('fieldset'); parent.disabled = true; document.body.appendChild(parent); - var input = document.createElement('input'); - var select = document.createElement('select'); - var button = document.createElement('button'); - var textarea = document.createElement('textarea'); + let input = document.createElement('input'); + let select = document.createElement('select'); + let button = document.createElement('button'); + let textarea = document.createElement('textarea'); parent.appendChild(input); parent.appendChild(select); parent.appendChild(button); parent.appendChild(textarea); - var listener1 = sinon.stub(); - var listener2 = sinon.stub(); - var listener3 = sinon.stub(); - var listener4 = sinon.stub(); + let listener1 = sinon.stub(); + let listener2 = sinon.stub(); + let listener3 = sinon.stub(); + let listener4 = sinon.stub(); input.addEventListener('click', listener1); select.addEventListener('click', listener2); @@ -507,14 +514,14 @@ describe('dom', function() { }); it('should trigger click event listeners for non-disabled elements even with its parent being disabled', function() { - var element = document.createElement('fieldset'); + let element = document.createElement('fieldset'); element.innerHTML = ''; element.disabled = true; document.body.appendChild(element); - var target = element.querySelector('.match'); + let target = element.querySelector('.match'); - var listener = sinon.stub(); + let listener = sinon.stub(); target.addEventListener('click', listener); dom.triggerEvent(target, 'click'); @@ -523,20 +530,21 @@ describe('dom', function() { }); it('should keep bubling and triggering click event listeners for non-disabled elements', function() { - var element = document.createElement('div'); - element.innerHTML = '
' + + let element = document.createElement('div'); + element.innerHTML = + '
' + '
'; document.body.appendChild(element); - var span = element.querySelector('span'); + let span = element.querySelector('span'); - var listeners = sinon.stub(); + let listeners = sinon.stub(); dom.delegate(element, 'click', '.match', listeners); dom.triggerEvent(span, 'click'); // Firefox works in a diferent way. It stops bubbling events when it hits a // disabled element. - var spectedResult = UA.isFirefox ? 0 : 2; + let spectedResult = UA.isFirefox ? 0 : 2; assert.strictEqual(spectedResult, listeners.callCount); }); }); @@ -544,17 +552,18 @@ describe('dom', function() { describe('delegate', function() { describe('selector', function() { it('should trigger delegate listener for matched elements', function() { - var element = document.createElement('div'); - element.innerHTML = '
' + + let element = document.createElement('div'); + element.innerHTML = + '
' + '
' + '
' + '
' + '
'; document.body.appendChild(element); - var matchedElements = element.querySelectorAll('.match'); + let matchedElements = element.querySelectorAll('.match'); - var listenerTargets = []; - var listener = function(event) { + let listenerTargets = []; + let listener = function(event) { listenerTargets.push(event.delegateTarget); }; dom.delegate(element, 'click', '.match', listener); @@ -566,17 +575,18 @@ describe('dom', function() { }); it('should trigger delegate listener for "focus" event', function() { - var element = document.createElement('div'); - element.innerHTML = '
' + + let element = document.createElement('div'); + element.innerHTML = + '
' + '
' + '
' + '
' + '
'; document.body.appendChild(element); - var matchedElements = element.querySelectorAll('.match'); + let matchedElements = element.querySelectorAll('.match'); - var listenerTargets = []; - var listener = function(event) { + let listenerTargets = []; + let listener = function(event) { listenerTargets.push(event.delegateTarget); }; dom.delegate(element, 'focus', '.match', listener); @@ -588,17 +598,18 @@ describe('dom', function() { }); it('should only trigger delegate event starting from initial target', function() { - var element = document.createElement('div'); - element.innerHTML = '
' + + let element = document.createElement('div'); + element.innerHTML = + '
' + '
' + '
' + '
' + '
'; document.body.appendChild(element); - var matchedElements = element.querySelectorAll('.match'); + let matchedElements = element.querySelectorAll('.match'); - var listenerTargets = []; - var listener = function(event) { + let listenerTargets = []; + let listener = function(event) { listenerTargets.push(event.delegateTarget); }; dom.delegate(element, 'click', '.match', listener); @@ -609,7 +620,7 @@ describe('dom', function() { }); it('should trigger listener twice when two ancestors are delegating', function() { - var element = document.createElement('div'); + let element = document.createElement('div'); element.innerHTML = `
@@ -617,7 +628,7 @@ describe('dom', function() {
`; document.body.appendChild(element); - var listener = sinon.stub(); + let listener = sinon.stub(); dom.delegate(element, 'click', '.match', listener); dom.delegate(element.childNodes[0], 'click', '.match', listener); @@ -626,13 +637,13 @@ describe('dom', function() { }); it('should not trigger delegate event for parents of given element', function() { - var element = document.createElement('div'); + let element = document.createElement('div'); element.innerHTML = '
'; element.className = 'match'; document.body.appendChild(element); - var childElement = element.childNodes[0]; - var listener = sinon.stub(); + let childElement = element.childNodes[0]; + let listener = sinon.stub(); dom.delegate(childElement, 'click', '.match', listener); dom.triggerEvent(childElement, 'click'); @@ -640,17 +651,18 @@ describe('dom', function() { }); it('should stop triggering event if stopPropagation is called', function() { - var element = document.createElement('div'); - element.innerHTML = '
' + + let element = document.createElement('div'); + element.innerHTML = + '
' + '
' + '
' + '
' + '
'; document.body.appendChild(element); - var matchedElements = element.querySelectorAll('.match'); + let matchedElements = element.querySelectorAll('.match'); - var listenerTargets = []; - var listener = function(event) { + let listenerTargets = []; + let listener = function(event) { listenerTargets.push(event.delegateTarget); event.stopPropagation(); }; @@ -662,17 +674,18 @@ describe('dom', function() { }); it('should stop triggering event if stopImmediatePropagation is called', function() { - var element = document.createElement('div'); - element.innerHTML = '
' + + let element = document.createElement('div'); + element.innerHTML = + '
' + '
' + '
' + '
' + '
'; document.body.appendChild(element); - var matchedElements = element.querySelectorAll('.match'); + let matchedElements = element.querySelectorAll('.match'); - var listenerTargets = []; - var listener = function(event) { + let listenerTargets = []; + let listener = function(event) { listenerTargets.push(event.delegateTarget); event.stopImmediatePropagation(); }; @@ -684,13 +697,13 @@ describe('dom', function() { }); it('should run default listeners last', function() { - var element = document.createElement('div'); + let element = document.createElement('div'); element.innerHTML = '
'; document.body.appendChild(element); - var listener1 = sinon.stub(); - var listener2 = sinon.stub(); - var listener3 = sinon.stub(); + let listener1 = sinon.stub(); + let listener2 = sinon.stub(); + let listener3 = sinon.stub(); dom.delegate(element, 'click', '.match', listener1, true); dom.delegate(element, 'click', '.match', listener2); dom.delegate(element, 'click', '.root', listener3); @@ -705,12 +718,12 @@ describe('dom', function() { }); it('should pass correct delegateTarget to default listener', function() { - var element = document.createElement('div'); + let element = document.createElement('div'); element.innerHTML = '
'; document.body.appendChild(element); - var target; - var listener = function(event) { + let target; + let listener = function(event) { target = event.delegateTarget; }; dom.delegate(element, 'click', '.match', listener, true); @@ -721,30 +734,33 @@ describe('dom', function() { }); it('should not run default listener if event is prevented', function() { - var element = document.createElement('div'); + let element = document.createElement('div'); element.innerHTML = '
'; document.body.appendChild(element); - var listener = sinon.stub(); + let listener = sinon.stub(); dom.delegate(element, 'click', '.match', listener, true); - dom.delegate(element, 'click', '.match', event => event.preventDefault()); + dom.delegate(element, 'click', '.match', event => + event.preventDefault() + ); dom.triggerEvent(element.querySelector('.match'), 'click'); assert.strictEqual(0, listener.callCount); }); it('should cancel listener through returned handle', function() { - var element = document.createElement('div'); - element.innerHTML = '
' + + let element = document.createElement('div'); + element.innerHTML = + '
' + '
' + '
' + '
' + '
'; document.body.appendChild(element); - var matchedElements = element.querySelectorAll('.match'); + let matchedElements = element.querySelectorAll('.match'); - var listener1 = sinon.stub(); - var handle = dom.delegate(element, 'click', '.match', listener1); + let listener1 = sinon.stub(); + let handle = dom.delegate(element, 'click', '.match', listener1); handle.removeListener(); dom.triggerEvent(matchedElements[0], 'click'); @@ -752,16 +768,17 @@ describe('dom', function() { }); it('should clear delegateTarget from event object after event is done', function() { - var element = document.createElement('div'); - element.innerHTML = '
' + + let element = document.createElement('div'); + element.innerHTML = + '
' + '
' + '
' + '
' + '
'; document.body.appendChild(element); - var matchedElements = element.querySelectorAll('.match'); + let matchedElements = element.querySelectorAll('.match'); - var listener = sinon.stub(); + let listener = sinon.stub(); dom.delegate(element, 'click', '.match', listener); dom.triggerEvent(matchedElements[1], 'click'); @@ -769,13 +786,13 @@ describe('dom', function() { }); it('should not run click event listeners for disabled elements', function() { - var parent = document.createElement('div'); + let parent = document.createElement('div'); document.body.appendChild(parent); - var input = document.createElement('input'); - var select = document.createElement('select'); - var button = document.createElement('button'); - var textarea = document.createElement('textarea'); + let input = document.createElement('input'); + let select = document.createElement('select'); + let button = document.createElement('button'); + let textarea = document.createElement('textarea'); input.disabled = true; select.disabled = true; button.disabled = true; @@ -785,10 +802,10 @@ describe('dom', function() { parent.appendChild(button); parent.appendChild(textarea); - var listener1 = sinon.stub(); - var listener2 = sinon.stub(); - var listener3 = sinon.stub(); - var listener4 = sinon.stub(); + let listener1 = sinon.stub(); + let listener2 = sinon.stub(); + let listener3 = sinon.stub(); + let listener4 = sinon.stub(); dom.delegate(parent, 'click', input, listener1); dom.delegate(parent, 'click', select, listener2); @@ -806,23 +823,23 @@ describe('dom', function() { }); it('should not run click event listeners to an element with an disabled valid parent', function() { - var parent = document.createElement('fieldset'); + let parent = document.createElement('fieldset'); parent.disabled = true; document.body.appendChild(parent); - var input = document.createElement('input'); - var select = document.createElement('select'); - var button = document.createElement('button'); - var textarea = document.createElement('textarea'); + let input = document.createElement('input'); + let select = document.createElement('select'); + let button = document.createElement('button'); + let textarea = document.createElement('textarea'); parent.appendChild(input); parent.appendChild(select); parent.appendChild(button); parent.appendChild(textarea); - var listener1 = sinon.stub(); - var listener2 = sinon.stub(); - var listener3 = sinon.stub(); - var listener4 = sinon.stub(); + let listener1 = sinon.stub(); + let listener2 = sinon.stub(); + let listener3 = sinon.stub(); + let listener4 = sinon.stub(); dom.delegate(parent, 'click', input, listener1); dom.delegate(parent, 'click', select, listener2); @@ -840,37 +857,38 @@ describe('dom', function() { }); it('should run click event listeners to an element that have not the disabled attribute with a disabled parent using "dispatchEvent()"', function() { - var element = document.createElement('div'); - element.innerHTML = '
' + + let element = document.createElement('div'); + element.innerHTML = + '
' + '
'; document.body.appendChild(element); - var listener = sinon.stub(); + let listener = sinon.stub(); dom.delegate(element, 'click', '.match', listener); - var eventObj = document.createEvent('HTMLEvents'); + let eventObj = document.createEvent('HTMLEvents'); eventObj.initEvent('click', true, true); - var target = element.querySelector('.match'); + let target = element.querySelector('.match'); target.dispatchEvent(eventObj); // Firefox works in a diferent way. It stops bubbling events when it hits a // disabled element. - var expectedResult = UA.isFirefox ? 0 : 1; + let expectedResult = UA.isFirefox ? 0 : 1; assert.strictEqual(expectedResult, listener.callCount); }); }); describe('without selector', function() { it('should trigger delegate listener for specified element', function() { - var element = document.createElement('div'); + let element = document.createElement('div'); dom.enterDocument(element); - var child = document.createElement('div'); + let child = document.createElement('div'); dom.append(element, child); - var grandchild = document.createElement('div'); + let grandchild = document.createElement('div'); dom.append(child, grandchild); - var eventCopy; + let eventCopy; dom.delegate(element, 'click', child, function(event) { eventCopy = object.mixin({}, event); }); @@ -892,11 +910,11 @@ describe('dom', function() { }); it('should not add listener to container twice for the same event type', function() { - var element = document.createElement('div'); + let element = document.createElement('div'); dom.enterDocument(element); - var child1 = document.createElement('div'); + let child1 = document.createElement('div'); dom.append(element, child1); - var child2 = document.createElement('div'); + let child2 = document.createElement('div'); dom.append(element, child2); sinon.spy(element, 'addEventListener'); @@ -906,16 +924,16 @@ describe('dom', function() { }); it('should trigger all delegated listeners for right element', function() { - var element = document.createElement('div'); + let element = document.createElement('div'); dom.enterDocument(element); - var child1 = document.createElement('div'); + let child1 = document.createElement('div'); dom.append(element, child1); - var child2 = document.createElement('div'); + let child2 = document.createElement('div'); dom.append(element, child2); - var child1Listener1 = sinon.stub(); - var child1Listener2 = sinon.stub(); - var child2Listener = sinon.stub(); + let child1Listener1 = sinon.stub(); + let child1Listener2 = sinon.stub(); + let child2Listener = sinon.stub(); dom.delegate(element, 'click', child1, child1Listener1); dom.delegate(element, 'click', child1, child1Listener2); dom.delegate(element, 'click', child2, child2Listener); @@ -932,17 +950,17 @@ describe('dom', function() { }); it('should not trigger listener twice when two ancestors are delegating', function() { - var element = document.createElement('div'); + let element = document.createElement('div'); dom.enterDocument(element); - var child = document.createElement('div'); + let child = document.createElement('div'); dom.append(element, child); - var grandchild = document.createElement('div'); + let grandchild = document.createElement('div'); dom.append(child, grandchild); - var greatgrandchild = document.createElement('div'); + let greatgrandchild = document.createElement('div'); dom.append(grandchild, greatgrandchild); - var listener1 = sinon.stub(); - var listener2 = sinon.stub(); + let listener1 = sinon.stub(); + let listener2 = sinon.stub(); dom.delegate(grandchild, 'click', greatgrandchild, listener1); dom.delegate(element, 'click', child, listener2); @@ -952,15 +970,15 @@ describe('dom', function() { }); it('should not trigger listeners from ancestors when stopPropagation is called', function() { - var element = document.createElement('div'); + let element = document.createElement('div'); dom.enterDocument(element); - var child = document.createElement('div'); + let child = document.createElement('div'); dom.append(element, child); - var grandchild = document.createElement('div'); + let grandchild = document.createElement('div'); dom.append(child, grandchild); - var listener1 = sinon.stub(); - var listener2 = sinon.stub(); + let listener1 = sinon.stub(); + let listener2 = sinon.stub(); dom.delegate(element, 'click', grandchild, function(event) { event.stopPropagation(); }); @@ -973,15 +991,15 @@ describe('dom', function() { }); it('should not trigger any other listeners when stopImmediatePropagation is called', function() { - var element = document.createElement('div'); + let element = document.createElement('div'); dom.enterDocument(element); - var child = document.createElement('div'); + let child = document.createElement('div'); dom.append(element, child); - var grandchild = document.createElement('div'); + let grandchild = document.createElement('div'); dom.append(child, grandchild); - var listener1 = sinon.stub(); - var listener2 = sinon.stub(); + let listener1 = sinon.stub(); + let listener2 = sinon.stub(); dom.delegate(element, 'click', grandchild, function(event) { event.stopImmediatePropagation(); }); @@ -994,30 +1012,30 @@ describe('dom', function() { }); it('should not trigger delegate "click" listener for right clicks', function() { - var element = document.createElement('div'); + let element = document.createElement('div'); dom.enterDocument(element); - var child = document.createElement('div'); + let child = document.createElement('div'); dom.append(element, child); - var listener = sinon.stub(); + let listener = sinon.stub(); dom.delegate(element, 'click', child, listener); dom.triggerEvent(child, 'click', { - button: 2 + button: 2, }); assert.strictEqual(0, listener.callCount); }); it('should run default listeners last', function() { - var element = document.createElement('div'); + let element = document.createElement('div'); dom.enterDocument(element); - var child = document.createElement('div'); + let child = document.createElement('div'); dom.append(element, child); - var grandchild = document.createElement('div'); + let grandchild = document.createElement('div'); dom.append(child, grandchild); - var listener1 = sinon.stub(); - var listener2 = sinon.stub(); - var listener3 = sinon.stub(); + let listener1 = sinon.stub(); + let listener2 = sinon.stub(); + let listener3 = sinon.stub(); dom.delegate(element, 'click', grandchild, listener1, true); dom.delegate(element, 'click', grandchild, listener2); dom.delegate(element, 'click', child, listener3); @@ -1032,12 +1050,12 @@ describe('dom', function() { }); it('should not run default listener if event is prevented', function() { - var element = document.createElement('div'); + let element = document.createElement('div'); dom.enterDocument(element); - var child = document.createElement('div'); + let child = document.createElement('div'); dom.append(element, child); - var listener = sinon.stub(); + let listener = sinon.stub(); dom.delegate(element, 'click', child, listener, true); dom.delegate(element, 'click', child, event => event.preventDefault()); @@ -1046,14 +1064,14 @@ describe('dom', function() { }); it('should cancel listener through returned handle', function() { - var element = document.createElement('div'); + let element = document.createElement('div'); dom.enterDocument(element); - var child = document.createElement('div'); + let child = document.createElement('div'); dom.append(element, child); - var listener1 = sinon.stub(); - var listener2 = sinon.stub(); - var handle = dom.delegate(element, 'click', child, listener1); + let listener1 = sinon.stub(); + let listener2 = sinon.stub(); + let handle = dom.delegate(element, 'click', child, listener1); dom.delegate(element, 'click', child, listener2); handle.removeListener(); @@ -1063,13 +1081,13 @@ describe('dom', function() { }); it('should cancel default listener through returned handle', function() { - var element = document.createElement('div'); + let element = document.createElement('div'); dom.enterDocument(element); - var child = document.createElement('div'); + let child = document.createElement('div'); dom.append(element, child); - var listener = sinon.stub(); - var handle = dom.delegate(element, 'click', child, listener, true); + let listener = sinon.stub(); + let handle = dom.delegate(element, 'click', child, listener, true); handle.removeListener(); dom.triggerEvent(child, 'click'); @@ -1077,12 +1095,12 @@ describe('dom', function() { }); it('should clear delegateTarget from event object after event is done', function() { - var element = document.createElement('div'); + let element = document.createElement('div'); dom.enterDocument(element); - var child = document.createElement('div'); + let child = document.createElement('div'); dom.append(element, child); - var listener = sinon.stub(); + let listener = sinon.stub(); dom.delegate(element, 'click', child, listener); dom.triggerEvent(child, 'click'); @@ -1113,9 +1131,9 @@ describe('dom', function() { }); it('should use matches function when available', function() { - var matchedElement = document.createElement('div'); + let matchedElement = document.createElement('div'); Element.prototype.matches = sinon.stub().returns(matchedElement); - var element = document.createElement('div'); + let element = document.createElement('div'); assert.strictEqual(matchedElement, dom.match(element, '.selector')); assert.strictEqual(1, element.matches.callCount); @@ -1123,10 +1141,12 @@ describe('dom', function() { }); it('should use webkitMatchesSelector function when available', function() { - var matchedElement = document.createElement('div'); + let matchedElement = document.createElement('div'); Element.prototype.matches = null; - Element.prototype.webkitMatchesSelector = sinon.stub().returns(matchedElement); - var element = document.createElement('div'); + Element.prototype.webkitMatchesSelector = sinon + .stub() + .returns(matchedElement); + let element = document.createElement('div'); assert.strictEqual(matchedElement, dom.match(element, '.selector')); assert.strictEqual(1, element.webkitMatchesSelector.callCount); @@ -1134,11 +1154,13 @@ describe('dom', function() { }); it('should use mozMatchesSelector function when available', function() { - var matchedElement = document.createElement('div'); + let matchedElement = document.createElement('div'); Element.prototype.matches = null; Element.prototype.webkitMatchesSelector = null; - Element.prototype.mozMatchesSelector = sinon.stub().returns(matchedElement); - var element = document.createElement('div'); + Element.prototype.mozMatchesSelector = sinon + .stub() + .returns(matchedElement); + let element = document.createElement('div'); assert.strictEqual(matchedElement, dom.match(element, '.selector')); assert.strictEqual(1, element.mozMatchesSelector.callCount); @@ -1146,12 +1168,14 @@ describe('dom', function() { }); it('should use msMatchesSelector function when available', function() { - var matchedElement = document.createElement('div'); + let matchedElement = document.createElement('div'); Element.prototype.matches = null; Element.prototype.webkitMatchesSelector = null; Element.prototype.mozMatchesSelector = null; - Element.prototype.msMatchesSelector = sinon.stub().returns(matchedElement); - var element = document.createElement('div'); + Element.prototype.msMatchesSelector = sinon + .stub() + .returns(matchedElement); + let element = document.createElement('div'); assert.strictEqual(matchedElement, dom.match(element, '.selector')); assert.strictEqual(1, element.msMatchesSelector.callCount); @@ -1159,13 +1183,13 @@ describe('dom', function() { }); it('should use oMatchesSelector function when available', function() { - var matchedElement = document.createElement('div'); + let matchedElement = document.createElement('div'); Element.prototype.matches = null; Element.prototype.webkitMatchesSelector = null; Element.prototype.mozMatchesSelector = null; Element.prototype.msMatchesSelector = null; Element.prototype.oMatchesSelector = sinon.stub().returns(matchedElement); - var element = document.createElement('div'); + let element = document.createElement('div'); assert.strictEqual(matchedElement, dom.match(element, '.selector')); assert.strictEqual(1, element.oMatchesSelector.callCount); @@ -1175,16 +1199,16 @@ describe('dom', function() { it('should return false for invalid node type', function() { Element.prototype.matches = sinon.stub(); - var element = document.createDocumentFragment(); + let element = document.createDocumentFragment(); assert.ok(!dom.match(element, 'selector')); assert.strictEqual(0, Element.prototype.matches.callCount); }); it('should fall back to using querySelectorAll when no others are available', function() { - var element = document.createElement('div'); + let element = document.createElement('div'); element.className = 'class1'; document.body.appendChild(element); - var element2 = document.createElement('div'); + let element2 = document.createElement('div'); element2.className = 'class2'; document.body.appendChild(element2); @@ -1205,9 +1229,9 @@ describe('dom', function() { dom.enterDocument( '
' ); - var element = dom.toElement('.element'); - var parent2 = dom.toElement('.parent1'); - var parent3 = dom.toElement('.parent2'); + let element = dom.toElement('.element'); + let parent2 = dom.toElement('.parent1'); + let parent3 = dom.toElement('.parent2'); assert.strictEqual(null, dom.parent(element, '.element')); assert.strictEqual(parent2, dom.parent(element, '.parent1')); assert.strictEqual(parent3, dom.parent(element, '.parent2')); @@ -1220,9 +1244,9 @@ describe('dom', function() { dom.enterDocument( '
' ); - var element = dom.toElement('.element'); - var parent2 = dom.toElement('.parent1'); - var parent3 = dom.toElement('.parent2'); + let element = dom.toElement('.element'); + let parent2 = dom.toElement('.parent1'); + let parent3 = dom.toElement('.parent2'); assert.strictEqual(element, dom.closest(element, '.element')); assert.strictEqual(parent2, dom.closest(element, '.parent1')); assert.strictEqual(parent3, dom.closest(element, '.parent2')); @@ -1235,9 +1259,9 @@ describe('dom', function() { dom.enterDocument( '
' ); - var element = dom.toElement('.rootElement'); - var sibling1 = dom.toElement('.sibling1'); - var sibling2 = dom.toElement('.sibling2'); + let element = dom.toElement('.rootElement'); + let sibling1 = dom.toElement('.sibling1'); + let sibling2 = dom.toElement('.sibling2'); assert.strictEqual(sibling1, dom.next(element, '.sibling1')); assert.strictEqual(sibling2, dom.next(element, '.sibling2')); assert.strictEqual(null, dom.next(element, '.sibling3')); @@ -1246,14 +1270,14 @@ describe('dom', function() { describe('toElement', function() { it('should return the element itself if one is given for conversion', function() { - var element = document.createElement('div'); + let element = document.createElement('div'); assert.strictEqual(element, dom.toElement(element)); assert.strictEqual(document, dom.toElement(document)); }); it('should return matching element if selector is given', function() { - var element = document.createElement('div'); + let element = document.createElement('div'); element.className = 'mySelector'; document.body.appendChild(element); @@ -1261,7 +1285,7 @@ describe('dom', function() { }); it('should return matching element when selector is id', function() { - var element = document.createElement('div'); + let element = document.createElement('div'); element.id = 'myId'; document.body.appendChild(element); @@ -1269,10 +1293,10 @@ describe('dom', function() { }); it('should return matching element when selector is inside id', function() { - var element = document.createElement('div'); + let element = document.createElement('div'); element.id = 'myId'; document.body.appendChild(element); - var element2 = document.createElement('div'); + let element2 = document.createElement('div'); element2.className = 'myClass'; dom.append(element, element2); @@ -1286,21 +1310,21 @@ describe('dom', function() { assert.strictEqual(null, dom.toElement(null)); }); - it('should return matching element if selector is document fragment', function () { - var frag1 = document.createDocumentFragment(); + it('should return matching element if selector is document fragment', function() { + let frag1 = document.createDocumentFragment(); assert.strictEqual(frag1, dom.toElement(frag1)); - var frag2 = document.createDocumentFragment(); + let frag2 = document.createDocumentFragment(); assert.strictEqual(frag2, dom.toElement(frag2)); - var frag3 = '#document-fragment'; + let frag3 = '#document-fragment'; assert.notStrictEqual(frag3, dom.toElement(frag3)); }); }); describe('supportsEvent', function() { it('should check if element supports event', function() { - var element = document.createElement('div'); + let element = document.createElement('div'); assert.ok(!dom.supportsEvent(element, 'lalala')); assert.ok(dom.supportsEvent(element, 'click')); @@ -1324,13 +1348,13 @@ describe('dom', function() { return listener(event); } }, - originalEvent: 'click' + originalEvent: 'click', }); }); it('should handle registered custom events', function() { - var listener = sinon.stub(); - var element = document.createElement('div'); + let listener = sinon.stub(); + let element = document.createElement('div'); dom.append(document.body, element); dom.on(element, 'myClick', listener); @@ -1343,19 +1367,19 @@ describe('dom', function() { }); it('should handle delegate for registered custom events', function() { - var element = document.createElement('div'); + let element = document.createElement('div'); dom.addClasses(element, 'mine'); dom.append(document.body, element); - var myElement = document.createElement('div'); + let myElement = document.createElement('div'); dom.addClasses(myElement, 'mine foo'); dom.append(element, myElement); - var fooElement = document.createElement('div'); + let fooElement = document.createElement('div'); dom.addClasses(fooElement, 'foo'); dom.append(element, fooElement); - var listener = sinon.stub(); + let listener = sinon.stub(); dom.delegate(element, 'myClick', '.foo', listener); dom.triggerEvent(element, 'click'); @@ -1376,7 +1400,7 @@ describe('dom', function() { describe('Helpers', function() { it('should check if element is empty', function() { - var element = document.createElement('div'); + let element = document.createElement('div'); assert.ok(dom.isEmpty(element)); element.innerHTML = 'foo'; @@ -1387,5 +1411,4 @@ describe('dom', function() { function getClassNames(element) { return element.className.trim().split(' '); } - }); diff --git a/packages/metal-dom/test/domData.js b/packages/metal-dom/test/domData.js index e1efebe1..2886e41b 100644 --- a/packages/metal-dom/test/domData.js +++ b/packages/metal-dom/test/domData.js @@ -4,18 +4,18 @@ import domData from '../src/domData'; describe('domData', function() { it('should get data object from element', function() { - var data = domData.get(document.createElement('div')); + let data = domData.get(document.createElement('div')); assert.ok(data); }); it('should return same data object for the same element', function() { - var element = document.createElement('div'); + let element = document.createElement('div'); assert.strictEqual(domData.get(element), domData.get(element)); }); it('should return different data objects for the different elements', function() { - var element1 = document.createElement('div'); - var element2 = document.createElement('div'); + let element1 = document.createElement('div'); + let element2 = document.createElement('div'); assert.notStrictEqual(domData.get(element1), domData.get(element2)); }); }); diff --git a/packages/metal-dom/test/events.js b/packages/metal-dom/test/events.js index 783cac5c..6ab322af 100644 --- a/packages/metal-dom/test/events.js +++ b/packages/metal-dom/test/events.js @@ -6,12 +6,12 @@ import '../src/events'; describe('Custom Events', function() { beforeEach(function() { - var element1 = document.createElement('div'); + let element1 = document.createElement('div'); dom.append(document.body, element1); - var element2 = document.createElement('div'); + let element2 = document.createElement('div'); dom.addClasses(element2, 'inner'); dom.append(element1, element2); - var element3 = document.createElement('div'); + let element3 = document.createElement('div'); dom.append(element2, element3); this.element1 = element1; @@ -20,85 +20,91 @@ describe('Custom Events', function() { }); it('should delegate mouseenter event', function() { - var listener = sinon.stub(); + let listener = sinon.stub(); dom.delegate(this.element1, 'mouseenter', '.inner', listener); dom.triggerEvent(this.element1, 'mouseover'); assert.strictEqual(0, listener.callCount); dom.triggerEvent(this.element2, 'mouseover', { - relatedTarget: this.element1 + relatedTarget: this.element1, }); assert.strictEqual(1, listener.callCount); assert.strictEqual('mouseenter', listener.args[0][0].customType); dom.triggerEvent(this.element2, 'mouseover', { - relatedTarget: this.element3 + relatedTarget: this.element3, }); assert.strictEqual(1, listener.callCount); }); it('should delegate mouseleave event', function() { - var listener = sinon.stub(); + let listener = sinon.stub(); dom.delegate(this.element1, 'mouseleave', '.inner', listener); dom.triggerEvent(this.element1, 'mouseout'); assert.strictEqual(0, listener.callCount); dom.triggerEvent(this.element2, 'mouseout', { - relatedTarget: this.element1 + relatedTarget: this.element1, }); assert.strictEqual(1, listener.callCount); assert.strictEqual('mouseleave', listener.args[0][0].customType); dom.triggerEvent(this.element2, 'mouseout', { - relatedTarget: this.element3 + relatedTarget: this.element3, }); assert.strictEqual(1, listener.callCount); }); it('should delegate pointerenter event', function() { - var listener = sinon.stub(); + let listener = sinon.stub(); dom.delegate(this.element1, 'pointerenter', '.inner', listener); dom.triggerEvent(this.element1, 'pointerover'); assert.strictEqual(0, listener.callCount); dom.triggerEvent(this.element2, 'pointerover', { - relatedTarget: this.element1 + relatedTarget: this.element1, }); assert.strictEqual(1, listener.callCount); assert.strictEqual('pointerenter', listener.args[0][0].customType); dom.triggerEvent(this.element2, 'pointerover', { - relatedTarget: this.element3 + relatedTarget: this.element3, }); assert.strictEqual(1, listener.callCount); }); it('should delegate pointerleave event', function() { - var listener = sinon.stub(); + let listener = sinon.stub(); dom.delegate(this.element1, 'pointerleave', '.inner', listener); dom.triggerEvent(this.element1, 'pointerout'); assert.strictEqual(0, listener.callCount); dom.triggerEvent(this.element2, 'pointerout', { - relatedTarget: this.element1 + relatedTarget: this.element1, }); assert.strictEqual(1, listener.callCount); assert.strictEqual('pointerleave', listener.args[0][0].customType); dom.triggerEvent(this.element2, 'pointerout', { - relatedTarget: this.element3 + relatedTarget: this.element3, }); assert.strictEqual(1, listener.callCount); }); it('should handle transitionend event', function() { - var listener = sinon.stub(); + let listener = sinon.stub(); dom.on(this.element1, 'transitionend', listener); - dom.triggerEvent(this.element1, features.checkAnimationEventName().transition); + dom.triggerEvent( + this.element1, + features.checkAnimationEventName().transition + ); assert.strictEqual(1, listener.callCount); assert.strictEqual('transitionend', listener.args[0][0].customType); }); it('should handle animationend event', function() { - var listener = sinon.stub(); + let listener = sinon.stub(); dom.on(this.element1, 'animationend', listener); - dom.triggerEvent(this.element1, features.checkAnimationEventName().animation); + dom.triggerEvent( + this.element1, + features.checkAnimationEventName().animation + ); assert.strictEqual(1, listener.callCount); assert.strictEqual('animationend', listener.args[0][0].customType); }); diff --git a/packages/metal-dom/test/features.js b/packages/metal-dom/test/features.js index 832be00c..7b3eb6e7 100644 --- a/packages/metal-dom/test/features.js +++ b/packages/metal-dom/test/features.js @@ -17,11 +17,11 @@ describe('features', function() { describe('Method checkAttrOrderChange', function() { it('should check if current browser changes attribute order', function() { - var result = features.checkAttrOrderChange(); + let result = features.checkAttrOrderChange(); assert.strictEqual(1, dom.append.callCount); - var element = dom.append.args[0][0]; - var original = dom.append.args[0][1]; + let element = dom.append.args[0][0]; + let original = dom.append.args[0][1]; assert.strictEqual(result, original !== element.innerHTML); }); @@ -45,39 +45,69 @@ describe('features', function() { it('should output default event name', function() { features.animationElement_ = { - style: {} + style: {}, }; - assert.strictEqual('animationend', features.checkAnimationEventName().animation); - assert.strictEqual('transitionend', features.checkAnimationEventName().transition); + assert.strictEqual( + 'animationend', + features.checkAnimationEventName().animation + ); + assert.strictEqual( + 'transitionend', + features.checkAnimationEventName().transition + ); }); it('should check for native browser support', function() { mockAnimationElementStyles(''); - assert.strictEqual('animationend', features.checkAnimationEventName().animation); - assert.strictEqual('transitionend', features.checkAnimationEventName().transition); + assert.strictEqual( + 'animationend', + features.checkAnimationEventName().animation + ); + assert.strictEqual( + 'transitionend', + features.checkAnimationEventName().transition + ); }); it('should check for Webkit browsers', function() { mockAnimationElementStyles('Webkit'); - assert.strictEqual('webkitAnimationEnd', features.checkAnimationEventName().animation); - assert.strictEqual('webkitTransitionEnd', features.checkAnimationEventName().transition); + assert.strictEqual( + 'webkitAnimationEnd', + features.checkAnimationEventName().animation + ); + assert.strictEqual( + 'webkitTransitionEnd', + features.checkAnimationEventName().transition + ); }); it('should check for MS browsers', function() { mockAnimationElementStyles('MS'); - assert.strictEqual('msAnimationEnd', features.checkAnimationEventName().animation); - assert.strictEqual('msTransitionEnd', features.checkAnimationEventName().transition); + assert.strictEqual( + 'msAnimationEnd', + features.checkAnimationEventName().animation + ); + assert.strictEqual( + 'msTransitionEnd', + features.checkAnimationEventName().transition + ); }); it('should check for Opera browsers', function() { mockAnimationElementStyles('O'); - assert.strictEqual('oAnimationEnd', features.checkAnimationEventName().animation); - assert.strictEqual('oTransitionEnd', features.checkAnimationEventName().transition); + assert.strictEqual( + 'oAnimationEnd', + features.checkAnimationEventName().animation + ); + assert.strictEqual( + 'oTransitionEnd', + features.checkAnimationEventName().transition + ); }); function mockAnimationElementStyles(browserPrefix) { features.animationElement_ = { - style: {} + style: {}, }; features.animationElement_.style[browserPrefix + 'animation'] = true; features.animationElement_.style[browserPrefix + 'transition'] = true; diff --git a/packages/metal-dom/test/globalEval.js b/packages/metal-dom/test/globalEval.js index cd03fd06..c764033b 100644 --- a/packages/metal-dom/test/globalEval.js +++ b/packages/metal-dom/test/globalEval.js @@ -1,6 +1,6 @@ 'use strict'; -import { async } from 'metal'; +import {async} from 'metal'; import * as dom from '../src/dom'; import globalEval from '../src/globalEval'; @@ -23,12 +23,12 @@ describe('globalEval', function() { }); it('should not leave created script tag in document after code is evaluated', function() { - var newScript = globalEval.run('var testScript = 2 + 2;'); + let newScript = globalEval.run('var testScript = 2 + 2;'); assert.ok(!newScript.parentNode); }); it('should evaluate script file in global scope', function(done) { - var newScript = globalEval.runFile('fixtures/script.js'); + let newScript = globalEval.runFile('fixtures/script.js'); dom.on(newScript, 'load', function() { assert.strictEqual(5, window.testScript); @@ -36,8 +36,10 @@ describe('globalEval', function() { }); }); - it('should remove created script tag after evaluated script file is loaded', function(done) { - var newScript = globalEval.runFile('fixtures/script.js'); + it('should remove created script tag after evaluated script file is loaded', function( + done + ) { + let newScript = globalEval.runFile('fixtures/script.js'); dom.on(newScript, 'load', function() { assert.ok(!newScript.parentNode); @@ -45,8 +47,10 @@ describe('globalEval', function() { }); }); - it('should remove created script tag after evaluated script file throws error', function(done) { - var newScript = globalEval.runFile('fixtures/unexistingScript.js'); + it('should remove created script tag after evaluated script file throws error', function( + done + ) { + let newScript = globalEval.runFile('fixtures/unexistingScript.js'); dom.on(newScript, 'error', function() { assert.ok(!newScript.parentNode); @@ -55,7 +59,7 @@ describe('globalEval', function() { }); it('should call callback function after script file is run', function(done) { - var newScript = globalEval.runFile('fixtures/script.js', function() { + const newScript = globalEval.runFile('fixtures/script.js', function() { assert.strictEqual(5, window.testScript); assert.ok(!newScript.parentNode); done(); @@ -63,8 +67,8 @@ describe('globalEval', function() { }); it('should be able to overwrite append function', function() { - var appendFn = sinon.stub(); - var script = document.createElement('script'); + let appendFn = sinon.stub(); + let script = document.createElement('script'); globalEval.runScript(script, null, appendFn); assert.strictEqual(1, appendFn.callCount); script.src = 'fixtures/script.js'; @@ -73,7 +77,7 @@ describe('globalEval', function() { }); it('should run code inside script tag in global scope', function() { - var script = document.createElement('script'); + let script = document.createElement('script'); script.text = 'var testScript = "script with code";'; globalEval.runScript(script); @@ -81,7 +85,7 @@ describe('globalEval', function() { }); it('should remove script element from the document when it\'s evaluated', function() { - var script = document.createElement('script'); + let script = document.createElement('script'); script.text = 'var testScript = "script with code";'; dom.enterDocument(script); @@ -90,8 +94,10 @@ describe('globalEval', function() { assert.ok(!script.parentNode); }); - it('should not evaluate script element with type different from javascript', function(done) { - var script = document.createElement('script'); + it('should not evaluate script element with type different from javascript', function( + done + ) { + let script = document.createElement('script'); script.text = 'Regular text file'; script.type = 'text/plain'; dom.enterDocument(script); @@ -104,8 +110,10 @@ describe('globalEval', function() { }); }); - it('should call callback function after script tag with inline content is run', function(done) { - var script = document.createElement('script'); + it('should call callback function after script tag with inline content is run', function( + done + ) { + let script = document.createElement('script'); script.text = 'var testScript = "script with code";'; dom.enterDocument(script); @@ -116,24 +124,28 @@ describe('globalEval', function() { }); }); - it('should run file referenced by specified script element in global scope', function(done) { - var script = document.createElement('script'); + it('should run file referenced by specified script element in global scope', function( + done + ) { + let script = document.createElement('script'); script.src = 'fixtures/script.js'; dom.enterDocument(script); - var newScript = globalEval.runScript(script); + let newScript = globalEval.runScript(script); dom.on(newScript, 'load', function() { assert.strictEqual(5, window.testScript); done(); }); }); - it('should call callback function after script tag with file src is run', function(done) { - var script = document.createElement('script'); + it('should call callback function after script tag with file src is run', function( + done + ) { + let script = document.createElement('script'); script.src = 'fixtures/script.js'; dom.enterDocument(script); - var newScript = globalEval.runScript(script, function() { + const newScript = globalEval.runScript(script, function() { assert.strictEqual(5, window.testScript); assert.ok(!newScript.parentNode); done(); @@ -141,7 +153,7 @@ describe('globalEval', function() { }); it('should run all script tags inside given element', function(done) { - var element = dom.buildFragment( + let element = dom.buildFragment( '
' ); globalEval.runScriptsInElement(element, function() { @@ -153,7 +165,7 @@ describe('globalEval', function() { }); it('should run script tags inside given element in order', function(done) { - var element = dom.buildFragment( + let element = dom.buildFragment( '
' ); @@ -164,29 +176,37 @@ describe('globalEval', function() { }); }); - it('should be able to overwrite append function from element', function(done) { - var element = dom.buildFragment( + it('should be able to overwrite append function from element', function( + done + ) { + let element = dom.buildFragment( '
' ); - var appendFn = sinon.spy(function(script) { + let appendFn = sinon.spy(function(script) { document.head.appendChild(script); }); - globalEval.runScriptsInElement(element, function() { - assert.strictEqual(2, appendFn.callCount); - done(); - }, appendFn); + globalEval.runScriptsInElement( + element, + function() { + assert.strictEqual(2, appendFn.callCount); + done(); + }, + appendFn + ); }); it('should not throw errors if trying to run scripts on element without any scripts', function() { - var element = dom.buildFragment('
'); + let element = dom.buildFragment('
'); assert.doesNotThrow(function() { globalEval.runScriptsInElement(element); }); }); - it('should call given callback on nextTick if no script tags exist in received element', function(done) { - var element = dom.buildFragment('
'); - var callback = sinon.stub(); + it('should call given callback on nextTick if no script tags exist in received element', function( + done + ) { + let element = dom.buildFragment('
'); + let callback = sinon.stub(); globalEval.runScriptsInElement(element, callback); assert.strictEqual(0, callback.callCount); async.nextTick(function() { diff --git a/packages/metal-dom/test/globalEvalStyles.js b/packages/metal-dom/test/globalEvalStyles.js index 811f0dd9..d4cbe7a8 100644 --- a/packages/metal-dom/test/globalEvalStyles.js +++ b/packages/metal-dom/test/globalEvalStyles.js @@ -1,6 +1,6 @@ 'use strict'; -import { async } from 'metal'; +import {async} from 'metal'; import * as dom from '../src/dom'; import globalEvalStyles from '../src/globalEvalStyles'; @@ -15,27 +15,29 @@ describe('globalEvalStyles', function() { afterEach(function() {}); it('should evaluate style code', function() { - var style = globalEvalStyles.run('body{background-color:rgb(255, 0, 0);}'); + let style = globalEvalStyles.run('body{background-color:rgb(255, 0, 0);}'); assertComputedStyle('backgroundColor', 'rgb(255, 0, 0)'); dom.exitDocument(style); }); it('should leave created style tag in document after code is evaluated', function() { - var style = globalEvalStyles.run(''); + let style = globalEvalStyles.run(''); assert.ok(style.parentNode); dom.exitDocument(style); }); it('should evaluate style file', function(done) { - var style = globalEvalStyles.runFile('fixtures/style.css', function() { + const style = globalEvalStyles.runFile('fixtures/style.css', function() { assertComputedStyle('backgroundColor', 'rgb(0, 255, 0)'); dom.exitDocument(style); done(); }); }); - it('should leave created style file in document after code is evaluated', function(done) { - var style = globalEvalStyles.runFile('fixtures/style.css', function() { + it('should leave created style file in document after code is evaluated', function( + done + ) { + const style = globalEvalStyles.runFile('fixtures/style.css', function() { assert.ok(style.parentNode); dom.exitDocument(style); done(); @@ -43,27 +45,31 @@ describe('globalEvalStyles', function() { }); it('should run code inside style tag in global scope', function() { - var style = document.createElement('style'); + let style = document.createElement('style'); style.innerHTML = 'body{background-color:rgb(255, 0, 0);}'; - var newStyle = globalEvalStyles.runStyle(style); + let newStyle = globalEvalStyles.runStyle(style); assertComputedStyle('backgroundColor', 'rgb(255, 0, 0)'); dom.exitDocument(newStyle); }); - it('should leave created style element in document after code is evaluated', function(done) { - var style = document.createElement('style'); + it('should leave created style element in document after code is evaluated', function( + done + ) { + let style = document.createElement('style'); style.innerHTML = 'body{background-color:rgb(255, 0, 0);}'; - var newStyle = globalEvalStyles.runStyle(style, function() { + const newStyle = globalEvalStyles.runStyle(style, function() { assert.ok(newStyle.parentNode); dom.exitDocument(newStyle); done(); }); }); - it('should not evaluate style element with tel different from stylesheet', function(done) { - var link = document.createElement('link'); + it('should not evaluate style element with tel different from stylesheet', function( + done + ) { + let link = document.createElement('link'); link.innerHTML = 'body{background-color:rgb(255, 0, 0);}'; link.rel = 'unknown'; dom.enterDocument(link); @@ -77,11 +83,11 @@ describe('globalEvalStyles', function() { }); it('should run file referenced by specified style element', function(done) { - var link = document.createElement('link'); + let link = document.createElement('link'); link.href = 'fixtures/style.css'; link.rel = 'stylesheet'; - var newStyle = globalEvalStyles.runStyle(link, function() { + const newStyle = globalEvalStyles.runStyle(link, function() { assertComputedStyle('backgroundColor', 'rgb(0, 255, 0)'); dom.exitDocument(newStyle); done(); @@ -89,9 +95,9 @@ describe('globalEvalStyles', function() { }); it('should be able to overwrite append function', function() { - var appendFn = sinon.stub(); - var style = document.createElement('style'); - var newStyle = globalEvalStyles.runStyle(style, null, appendFn); + let appendFn = sinon.stub(); + let style = document.createElement('style'); + let newStyle = globalEvalStyles.runStyle(style, null, appendFn); assert.strictEqual(1, appendFn.callCount); dom.exitDocument(newStyle); globalEvalStyles.run('', appendFn); @@ -99,7 +105,7 @@ describe('globalEvalStyles', function() { }); it('should run all styles tags inside given element', function(done) { - var element = dom.buildFragment( + let element = dom.buildFragment( '
' ); globalEvalStyles.runStylesInElement(element, function() { @@ -110,7 +116,7 @@ describe('globalEvalStyles', function() { }); it('should run styles tags inside given element in order', function(done) { - var element = dom.buildFragment( + let element = dom.buildFragment( '
' ); globalEvalStyles.runStylesInElement(element, function() { @@ -120,15 +126,17 @@ describe('globalEvalStyles', function() { }); it('should not throw errors if trying to run styles on element without any styles', function() { - var element = dom.buildFragment('
'); + let element = dom.buildFragment('
'); assert.doesNotThrow(function() { globalEvalStyles.runStylesInElement(element); }); }); - it('should call given callback on nextTick if no style tags exist in received element', function(done) { - var element = dom.buildFragment('
'); - var callback = sinon.stub(); + it('should call given callback on nextTick if no style tags exist in received element', function( + done + ) { + let element = dom.buildFragment('
'); + let callback = sinon.stub(); globalEvalStyles.runStylesInElement(element, callback); assert.strictEqual(0, callback.callCount); async.nextTick(function() { @@ -136,10 +144,11 @@ describe('globalEvalStyles', function() { done(); }); }); - }); - function assertComputedStyle(property, value) { - assert.strictEqual(value, window.getComputedStyle(document.body, null)[property]); + assert.strictEqual( + value, + window.getComputedStyle(document.body, null)[property] + ); } diff --git a/packages/metal-events/package-lock.json b/packages/metal-events/package-lock.json index f9c637f5..7e4c66d6 100644 --- a/packages/metal-events/package-lock.json +++ b/packages/metal-events/package-lock.json @@ -64,7 +64,7 @@ "lodash": "4.17.4", "minimatch": "3.0.4", "path-is-absolute": "1.0.1", - "private": "0.1.7", + "private": "0.1.8", "slash": "1.0.0", "source-map": "0.5.7" } @@ -507,9 +507,9 @@ } }, "babel-preset-env": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/babel-preset-env/-/babel-preset-env-1.6.0.tgz", - "integrity": "sha512-OVgtQRuOZKckrILgMA5rvctvFZPv72Gua9Rt006AiPoB0DJKGN07UmaQA+qRrYgK71MVct8fFhT0EyNWYorVew==", + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/babel-preset-env/-/babel-preset-env-1.6.1.tgz", + "integrity": "sha512-W6VIyA6Ch9ePMI7VptNn2wBM6dbG0eSz25HEiL40nQXCsXGTGZSTZu1Iap+cj3Q0S5a7T9+529l/5Bkvd+afNA==", "requires": { "babel-plugin-check-es2015-constants": "6.22.0", "babel-plugin-syntax-trailing-function-commas": "6.22.0", @@ -538,7 +538,7 @@ "babel-plugin-transform-es2015-unicode-regex": "6.24.1", "babel-plugin-transform-exponentiation-operator": "6.24.1", "babel-plugin-transform-regenerator": "6.26.0", - "browserslist": "2.5.1", + "browserslist": "2.8.0", "invariant": "2.2.2", "semver": "5.4.1" } @@ -625,18 +625,18 @@ } }, "browserslist": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-2.5.1.tgz", - "integrity": "sha512-jAvM2ku7YDJ+leAq3bFH1DE0Ylw+F+EQDq4GkqZfgPEqpWYw9ofQH85uKSB9r3Tv7XDbfqVtE+sdvKJW7IlPJA==", + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-2.8.0.tgz", + "integrity": "sha512-iiWHM1Et6Q4TQpB7Ar6pxuM3TNMXasVJY4Y/oh3q38EwR3Z+IdZ9MyVf7PI4MJFB4xpwMcZgs9bEUnPG2E3TCA==", "requires": { - "caniuse-lite": "1.0.30000746", - "electron-to-chromium": "1.3.25" + "caniuse-lite": "1.0.30000760", + "electron-to-chromium": "1.3.27" } }, "caniuse-lite": { - "version": "1.0.30000746", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000746.tgz", - "integrity": "sha1-xk+Vo5Jc/TAgejCO12wa6W6gnqA=" + "version": "1.0.30000760", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000760.tgz", + "integrity": "sha1-7HIDlXQvHH7IlH/W3SYE53qPmP8=" }, "chalk": { "version": "1.1.3", @@ -687,9 +687,9 @@ } }, "electron-to-chromium": { - "version": "1.3.25", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.25.tgz", - "integrity": "sha1-RTshAJg20Jl9hgNWAf9srkeRxGA=" + "version": "1.3.27", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.27.tgz", + "integrity": "sha1-eOy4o5kGYYe7N07t412ccFZagD0=" }, "escape-string-regexp": { "version": "1.0.5", @@ -879,9 +879,9 @@ "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" }, "private": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/private/-/private-0.1.7.tgz", - "integrity": "sha1-aM5eih7woju1cMwoU3tTMqumPvE=" + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/private/-/private-0.1.8.tgz", + "integrity": "sha512-VvivMrbvd2nKkiG38qjULzlc+4Vx4wm/whI9pQD35YrARNnhxeiRktSOhSukRLFNlzg6Br/cJPet5J/u19r/mg==" }, "regenerate": { "version": "1.3.3", @@ -900,7 +900,7 @@ "requires": { "babel-runtime": "6.26.0", "babel-types": "6.26.0", - "private": "0.1.7" + "private": "0.1.8" } }, "regexpu-core": { diff --git a/packages/metal-events/src/EventEmitter.js b/packages/metal-events/src/EventEmitter.js index 9c55a1b3..2410e7c1 100644 --- a/packages/metal-events/src/EventEmitter.js +++ b/packages/metal-events/src/EventEmitter.js @@ -1,16 +1,18 @@ 'use strict'; -import { array, Disposable, isFunction, isString } from 'metal'; +import {array, Disposable, isFunction, isString} from 'metal'; import EventHandle from './EventHandle'; const singleArray_ = [0]; /** * EventEmitter utility. - * @constructor * @extends {Disposable} */ class EventEmitter extends Disposable { + /** + * EventEmitter constructor + */ constructor() { super(); @@ -63,17 +65,17 @@ class EventEmitter extends Disposable { * Adds a listener to the end of the listeners array for the specified events. * @param {!(Array|string)} event * @param {!Function} listener - * @param {boolean} opt_default Flag indicating if this listener is a default + * @param {boolean} defaultListener Flag indicating if this listener is a default * action for this event. Default actions are run last, and only if no previous * listener call `preventDefault()` on the received event facade. * @return {!EventHandle} Can be used to remove the listener. */ - addListener(event, listener, opt_default) { + addListener(event, listener, defaultListener) { this.validateListener_(listener); const events = this.toEventsArray_(event); for (let i = 0; i < events.length; i++) { - this.addSingleListener_(events[i], listener, opt_default); + this.addSingleListener_(events[i], listener, defaultListener); } return new EventHandle(this, event, listener); @@ -83,21 +85,20 @@ class EventEmitter extends Disposable { * Adds a listener to the end of the listeners array for a single event. * @param {string} event * @param {!Function} listener - * @param {boolean} opt_default Flag indicating if this listener is a default + * @param {boolean} defaultListener Flag indicating if this listener is a default * action for this event. Default actions are run last, and only if no previous * listener call `preventDefault()` on the received event facade. - * @return {!EventHandle} Can be used to remove the listener. - * @param {Function=} opt_origin The original function that was added as a + * @param {Function=} origin The original function that was added as a * listener, if there is any. * @protected */ - addSingleListener_(event, listener, opt_default, opt_origin) { + addSingleListener_(event, listener, defaultListener, origin) { this.runListenerHandlers_(event); - if (opt_default || opt_origin) { + if (defaultListener || origin) { listener = { - default: opt_default, + default: defaultListener, fn: listener, - origin: opt_origin + origin: origin, }; } this.events_ = this.events_ || {}; @@ -117,7 +118,7 @@ class EventEmitter extends Disposable { facade.preventedDefault = true; }, target: this, - type: event + type: event, }; return facade; } @@ -143,7 +144,7 @@ class EventEmitter extends Disposable { return false; } - const args = array.slice(arguments, 1); + const args = array.slice(arguments, 1); // eslint-disable-line this.runListeners_(listeners, args, this.buildFacade_(event)); return true; } @@ -176,7 +177,7 @@ class EventEmitter extends Disposable { */ listeners(event) { return this.getRawListeners_(event).map( - listener => listener.fn ? listener.fn : listener + listener => (listener.fn ? listener.fn : listener) ); } @@ -216,11 +217,14 @@ class EventEmitter extends Disposable { return; } + /** + * + */ function handlerInternal() { if (--amount === 0) { self.removeListener(event, handlerInternal); } - listener.apply(self, arguments); + listener.apply(self, arguments); // eslint-disable-line } self.addSingleListener_(event, handlerInternal, false, listener); @@ -236,14 +240,15 @@ class EventEmitter extends Disposable { */ matchesListener_(listenerObj, listener) { const fn = listenerObj.fn || listenerObj; - return fn === listener || - (listenerObj.origin && listenerObj.origin === listener); + return ( + fn === listener || (listenerObj.origin && listenerObj.origin === listener) // eslint-disable-line + ); } /** * Removes a listener for the specified events. * Caution: changes array indices in the listener array behind the listener. - * @param {!(Array|string)} events + * @param {!(Array|string)} event * @param {!Function} listener * @return {!Object} Returns emitter, so calls can be chained. */ @@ -271,16 +276,16 @@ class EventEmitter extends Disposable { * @return {!EventHandle} Can be used to remove the listener. */ on() { - return this.addListener.apply(this, arguments); + return this.addListener.apply(this, arguments); // eslint-disable-line } /** * Adds handler that gets triggered when an event is listened to on this * instance. - * @param {!function()} + * @param {!function()} handler */ onListener(handler) { - this.listenerHandlers_ = this.addHandler_(this.listenerHandlers_, handler); + this.listenerHandlers_ = this.addHandler_(this.listenerHandlers_, handler); // eslint-disable-line } /** @@ -298,13 +303,13 @@ class EventEmitter extends Disposable { * Removes all listeners, or those of the specified events. It's not a good * idea to remove listeners that were added elsewhere in the code, * especially when it's on an emitter that you didn't create. - * @param {(Array|string)=} opt_events + * @param {(Array|string)=} event * @return {!Object} Returns emitter, so calls can be chained. */ - removeAllListeners(opt_events) { + removeAllListeners(event) { if (this.events_) { - if (opt_events) { - const events = this.toEventsArray_(opt_events); + if (event) { + const events = this.toEventsArray_(event); for (let i = 0; i < events.length; i++) { this.events_[events[i]] = null; } @@ -341,7 +346,7 @@ class EventEmitter extends Disposable { * @return {!Object} Returns emitter, so calls can be chained. */ removeListener() { - return this.off.apply(this, arguments); + return this.off.apply(this, arguments); // eslint-disable-line } /** @@ -363,7 +368,7 @@ class EventEmitter extends Disposable { * Runs the given listeners. * @param {!Array} listeners * @param {!Array} args - * @param (Object) facade + * @param {Object} facade * @protected */ runListeners_(listeners, args, facade) { @@ -427,6 +432,11 @@ class EventEmitter extends Disposable { } } +/** + * Converts to an array + * @param {Object} val + * @return {Array} + */ function toArray(val) { val = val || []; return Array.isArray(val) ? val : [val]; diff --git a/packages/metal-events/src/EventEmitterProxy.js b/packages/metal-events/src/EventEmitterProxy.js index eb702a52..314348f6 100644 --- a/packages/metal-events/src/EventEmitterProxy.js +++ b/packages/metal-events/src/EventEmitterProxy.js @@ -1,23 +1,25 @@ 'use strict'; -import { Disposable } from 'metal'; +import {Disposable} from 'metal'; /** * EventEmitterProxy utility. It's responsible for linking two EventEmitter * instances together, emitting events from the first emitter through the * second one. That means that listening to a supported event on the target * emitter will mean listening to it on the origin emitter as well. - * @param {EventEmitter} originEmitter Events originated on this emitter - * will be fired for the target emitter's listeners as well. - * @param {EventEmitter} targetEmitter Event listeners attached to this emitter - * will also be triggered when the event is fired by the origin emitter. - * @param {Object} opt_blacklist Optional blacklist of events that should not be - * proxied. - * @constructor * @extends {Disposable} */ class EventEmitterProxy extends Disposable { - constructor(originEmitter, targetEmitter, opt_blacklist, opt_whitelist) { + /** + * @param {EventEmitter} originEmitter Events originated on this emitter + * will be fired for the target emitter's listeners as well. + * @param {EventEmitter} targetEmitter Event listeners attached to this emitter + * will also be triggered when the event is fired by the origin emitter. + * @param {Object} blacklist Optional blacklist of events that should not be + * proxied. + * @param {Object} whitelist + */ + constructor(originEmitter, targetEmitter, blacklist, whitelist) { super(); /** @@ -25,7 +27,7 @@ class EventEmitterProxy extends Disposable { * @type {Object} * @protected */ - this.blacklist_ = opt_blacklist; + this.blacklist_ = blacklist; /** * The origin emitter. This emitter's events will be proxied through the @@ -64,7 +66,7 @@ class EventEmitterProxy extends Disposable { * @type {Object} * @protected */ - this.whitelist_ = opt_whitelist; + this.whitelist_ = whitelist; this.startProxy_(); } @@ -94,8 +96,8 @@ class EventEmitterProxy extends Disposable { * Emits the specified event type on the target emitter. * @protected */ - emitOnTarget_() { - this.targetEmitter_.emit.apply(this.targetEmitter_, arguments); + emitOnTarget_(...args) { + this.targetEmitter_.emit(...args); } /** @@ -130,9 +132,10 @@ class EventEmitterProxy extends Disposable { * @param {!EventEmitter} originEmitter */ setOriginEmitter(originEmitter) { - const events = this.originEmitter_ && this.proxiedEvents_ ? - Object.keys(this.proxiedEvents_) : - this.pendingEvents_; + const events = + this.originEmitter_ && this.proxiedEvents_ + ? Object.keys(this.proxiedEvents_) + : this.pendingEvents_; this.originEmitter_ = originEmitter; if (events) { this.removeListeners_(); diff --git a/packages/metal-events/src/EventHandle.js b/packages/metal-events/src/EventHandle.js index 6c1a1c53..fc992798 100644 --- a/packages/metal-events/src/EventHandle.js +++ b/packages/metal-events/src/EventHandle.js @@ -1,6 +1,6 @@ 'use strict'; -import { Disposable } from 'metal'; +import {Disposable} from 'metal'; /** * EventHandle utility. Holds information about an event subscription, and @@ -8,13 +8,15 @@ import { Disposable } from 'metal'; * EventHandle is a Disposable, but it's important to note that the * EventEmitter that created it is not the one responsible for disposing it. * That responsibility is for the code that holds a reference to it. - * @param {!EventEmitter} emitter Emitter the event was subscribed to. - * @param {string} event The name of the event that was subscribed to. - * @param {!Function} listener The listener subscribed to the event. - * @constructor * @extends {Disposable} */ class EventHandle extends Disposable { + /** + * EventHandle constructor + * @param {!EventEmitter} emitter Emitter the event was subscribed to. + * @param {string} event The name of the event that was subscribed to. + * @param {!Function} listener The listener subscribed to the event. + */ constructor(emitter, event, listener) { super(); diff --git a/packages/metal-events/src/EventHandler.js b/packages/metal-events/src/EventHandler.js index f76793e3..665c7824 100644 --- a/packages/metal-events/src/EventHandler.js +++ b/packages/metal-events/src/EventHandler.js @@ -1,14 +1,16 @@ 'use strict'; -import { Disposable } from 'metal'; +import {Disposable} from 'metal'; /** * EventHandler utility. It's useful for easily removing a group of * listeners from different EventEmitter instances. - * @constructor * @extends {Disposable} */ class EventHandler extends Disposable { + /** + * EventHandler constructor + */ constructor() { super(); @@ -26,9 +28,9 @@ class EventHandler extends Disposable { * method. * @param {...(!EventHandle)} var_args */ - add() { + add(...args) { for (let i = 0; i < arguments.length; i++) { - this.eventHandles_.push(arguments[i]); + this.eventHandles_.push(args[i]); } } diff --git a/packages/metal-events/src/events.js b/packages/metal-events/src/events.js index 4bb9487b..594a8a0a 100644 --- a/packages/metal-events/src/events.js +++ b/packages/metal-events/src/events.js @@ -6,4 +6,4 @@ import EventHandle from './EventHandle'; import EventHandler from './EventHandler'; export default EventEmitter; -export { EventEmitter, EventEmitterProxy, EventHandle, EventHandler }; +export {EventEmitter, EventEmitterProxy, EventHandle, EventHandler}; diff --git a/packages/metal-component/test/.eslintrc.json b/packages/metal-events/test/.eslintrc similarity index 51% rename from packages/metal-component/test/.eslintrc.json rename to packages/metal-events/test/.eslintrc index 92b466f1..f6269b7a 100644 --- a/packages/metal-component/test/.eslintrc.json +++ b/packages/metal-events/test/.eslintrc @@ -5,5 +5,10 @@ "globals": { "assert": true, "sinon": true + }, + "rules": { + "max-len": 0, + "no-invalid-this": 0, + "require-jsdoc": 0 } -} +} \ No newline at end of file diff --git a/packages/metal-events/test/EventEmitter.js b/packages/metal-events/test/EventEmitter.js index 2e0762ca..5aacc0da 100644 --- a/packages/metal-events/test/EventEmitter.js +++ b/packages/metal-events/test/EventEmitter.js @@ -12,7 +12,7 @@ describe('EventEmitter', function() { }); it('should emit and listen to events', function() { - var listener = sinon.stub(); + let listener = sinon.stub(); this.emitter.emit('event'); assert.strictEqual(0, listener.callCount); @@ -24,7 +24,7 @@ describe('EventEmitter', function() { }); it('should listen to multiple events on the same call', function() { - var listener = sinon.stub(); + let listener = sinon.stub(); this.emitter.on(['event1', 'event2'], listener); @@ -36,7 +36,7 @@ describe('EventEmitter', function() { }); it('should listen to events through `addListener`', function() { - var listener = sinon.stub(); + let listener = sinon.stub(); this.emitter.addListener(['event1', 'event2'], listener); @@ -48,7 +48,7 @@ describe('EventEmitter', function() { }); it('should listen to event a single time through `once`', function() { - var listener = sinon.stub(); + let listener = sinon.stub(); this.emitter.once('event', listener); assert.strictEqual(0, listener.callCount); @@ -61,7 +61,7 @@ describe('EventEmitter', function() { }); it('should listen to multiple events on the same call to `once`', function() { - var listener = sinon.stub(); + let listener = sinon.stub(); this.emitter.once(['event', 'event2'], listener); assert.strictEqual(0, listener.callCount); @@ -80,7 +80,7 @@ describe('EventEmitter', function() { }); it('should listen to event a fixed number of times through `many`', function() { - var listener = sinon.stub(); + let listener = sinon.stub(); this.emitter.many('event', 2, listener); assert.strictEqual(0, listener.callCount); @@ -96,7 +96,7 @@ describe('EventEmitter', function() { }); it('should listen to multiple events on the same call to `many`', function() { - var listener = sinon.stub(); + let listener = sinon.stub(); this.emitter.many(['event', 'event2'], 2, listener); @@ -120,7 +120,7 @@ describe('EventEmitter', function() { }); it('should ignore calls to `many` with non positive number', function() { - var listener = sinon.stub(); + let listener = sinon.stub(); this.emitter.many('event', 0, listener); this.emitter.emit('event'); @@ -132,11 +132,11 @@ describe('EventEmitter', function() { }); it('should run listeners in the order they were added', function() { - var order = ''; - var listener1 = function() { + let order = ''; + let listener1 = function() { order += '1'; }; - var listener2 = function() { + let listener2 = function() { order += '2'; }; @@ -148,9 +148,9 @@ describe('EventEmitter', function() { }); it('should return all listeners for given event type', function() { - var listener1 = sinon.stub(); - var listener2 = sinon.stub(); - var listener3 = sinon.stub(); + let listener1 = sinon.stub(); + let listener2 = sinon.stub(); + let listener3 = sinon.stub(); this.emitter.on('event', listener1); this.emitter.on('anotherEvent', listener2); @@ -162,8 +162,8 @@ describe('EventEmitter', function() { }); it('should detach events', function() { - var listener = sinon.stub(); - var listener2 = sinon.stub(); + let listener = sinon.stub(); + let listener2 = sinon.stub(); this.emitter.on('event', listener); this.emitter.on('event', listener2); @@ -175,8 +175,8 @@ describe('EventEmitter', function() { }); it('should detach listeners subscribed multiple times to same event', function() { - var listener = sinon.stub(); - var listener2 = sinon.stub(); + let listener = sinon.stub(); + let listener2 = sinon.stub(); this.emitter.on('event', listener); this.emitter.on('event', listener); @@ -190,11 +190,11 @@ describe('EventEmitter', function() { }); it('should detach events via return value', function() { - var listener = sinon.stub(); - var listener2 = sinon.stub(); + let listener = sinon.stub(); + let listener2 = sinon.stub(); this.emitter.on('event', listener); - var handle = this.emitter.on('event', listener2); + let handle = this.emitter.on('event', listener2); handle.removeListener(); this.emitter.emit('event'); @@ -203,8 +203,8 @@ describe('EventEmitter', function() { }); it('should detach events that were listened together', function() { - var listener = sinon.stub(); - var listener2 = sinon.stub(); + let listener = sinon.stub(); + let listener2 = sinon.stub(); this.emitter.on(['event', 'event2'], listener); this.emitter.on(['event', 'event2'], listener2); @@ -220,8 +220,8 @@ describe('EventEmitter', function() { }); it('should detach multiple events with the same call', function() { - var listener = sinon.stub(); - var listener2 = sinon.stub(); + let listener = sinon.stub(); + let listener2 = sinon.stub(); this.emitter.on('event', listener); this.emitter.on('event2', listener); @@ -238,11 +238,11 @@ describe('EventEmitter', function() { }); it('should detach events that were listened together via return value', function() { - var listener = sinon.stub(); - var listener2 = sinon.stub(); + let listener = sinon.stub(); + let listener2 = sinon.stub(); this.emitter.on(['event', 'event2'], listener); - var handle = this.emitter.on(['event', 'event2'], listener2); + let handle = this.emitter.on(['event', 'event2'], listener2); handle.removeListener(); this.emitter.emit('event'); @@ -255,7 +255,7 @@ describe('EventEmitter', function() { }); it('should detach events listened through `once`', function() { - var listener = sinon.stub(); + let listener = sinon.stub(); this.emitter.once('event', listener); this.emitter.off('event', listener); @@ -265,9 +265,9 @@ describe('EventEmitter', function() { }); it('should detach events listened through `once` via return value', function() { - var listener = sinon.stub(); + let listener = sinon.stub(); - var handle = this.emitter.once('event', listener); + let handle = this.emitter.once('event', listener); handle.removeListener(); this.emitter.emit('event'); @@ -275,7 +275,7 @@ describe('EventEmitter', function() { }); it('should detach events listened through `many`', function() { - var listener = sinon.stub(); + let listener = sinon.stub(); this.emitter.many('event', 2, listener); this.emitter.off('event', listener); @@ -285,7 +285,7 @@ describe('EventEmitter', function() { }); it('should detach events listened together through `many`', function() { - var listener = sinon.stub(); + let listener = sinon.stub(); this.emitter.many(['event', 'event2'], 2, listener); this.emitter.off(['event', 'event2'], listener); @@ -296,9 +296,9 @@ describe('EventEmitter', function() { }); it('should detach events listened together through `many` via return value', function() { - var listener = sinon.stub(); + let listener = sinon.stub(); - var handle = this.emitter.many(['event', 'event2'], 2, listener); + let handle = this.emitter.many(['event', 'event2'], 2, listener); handle.removeListener(); this.emitter.emit('event'); @@ -307,9 +307,9 @@ describe('EventEmitter', function() { }); it('should detach events listened through `many` via return value', function() { - var listener = sinon.stub(); + let listener = sinon.stub(); - var handle = this.emitter.many('event', 2, listener); + let handle = this.emitter.many('event', 2, listener); handle.removeListener(); this.emitter.emit('event'); @@ -317,8 +317,8 @@ describe('EventEmitter', function() { }); it('should detach events through `removeListener`', function() { - var listener = sinon.stub(); - var listener2 = sinon.stub(); + let listener = sinon.stub(); + let listener2 = sinon.stub(); this.emitter.on('event', listener); this.emitter.on('event', listener2); @@ -330,15 +330,17 @@ describe('EventEmitter', function() { }); it('should not throw error when detaching event type that was never used before', function() { - var listener = sinon.stub(); - assert.doesNotThrow(function() { - this.emitter.off('event', listener); - }.bind(this)); + let listener = sinon.stub(); + assert.doesNotThrow( + function() { + this.emitter.off('event', listener); + }.bind(this) + ); }); it('should remove all listeners', function() { - var listener1 = sinon.stub(); - var listener2 = sinon.stub(); + let listener1 = sinon.stub(); + let listener2 = sinon.stub(); this.emitter.on('event1', listener1); this.emitter.on('event2', listener2); @@ -352,8 +354,8 @@ describe('EventEmitter', function() { }); it('should remove all listeners of the given type', function() { - var listener1 = sinon.stub(); - var listener2 = sinon.stub(); + let listener1 = sinon.stub(); + let listener2 = sinon.stub(); this.emitter.on('event1', listener1); this.emitter.on('event2', listener2); @@ -367,9 +369,9 @@ describe('EventEmitter', function() { }); it('should remove all listeners of the given types', function() { - var listener1 = sinon.stub(); - var listener2 = sinon.stub(); - var listener3 = sinon.stub(); + let listener1 = sinon.stub(); + let listener2 = sinon.stub(); + let listener3 = sinon.stub(); this.emitter.on('event1', listener1); this.emitter.on('event2', listener2); @@ -391,7 +393,7 @@ describe('EventEmitter', function() { }); it('should only allow functions as listeners', function() { - var self = this; + let self = this; assert.throws(function() { self.emitter.addListener('event', {}); @@ -403,7 +405,7 @@ describe('EventEmitter', function() { }); it('should pass requested arguments to listener on emit', function() { - var listener = sinon.stub(); + let listener = sinon.stub(); this.emitter.on('event', listener); this.emitter.emit('event', 'arg1', 2); @@ -412,7 +414,7 @@ describe('EventEmitter', function() { }); it('should pass facade as last argument when requested', function() { - var listener = sinon.stub(); + let listener = sinon.stub(); this.emitter.setShouldUseFacade(true); this.emitter.on('event', listener); @@ -425,13 +427,13 @@ describe('EventEmitter', function() { sinon.match({ preventDefault: sinon.match.func, target: this.emitter, - type: 'event' + type: 'event', }) ); }); it('should set preventedDefault flag to true on facade when preventDefault is called', function() { - var listener = sinon.stub(); + let listener = sinon.stub(); this.emitter.setShouldUseFacade(true); this.emitter.once('event', function(event) { @@ -446,9 +448,9 @@ describe('EventEmitter', function() { }); it('should emit listener marked as default last', function() { - var listener1 = sinon.stub(); - var listener2 = sinon.stub(); - var listenerDefault = sinon.spy(function() { + let listener1 = sinon.stub(); + let listener2 = sinon.stub(); + let listenerDefault = sinon.spy(function() { assert.strictEqual(1, listener1.callCount); assert.strictEqual(1, listener2.callCount); }); @@ -462,11 +464,11 @@ describe('EventEmitter', function() { }); it('should not call default listener if "preventDefault" is called', function() { - var listener1 = sinon.spy(function(event) { + let listener1 = sinon.spy(function(event) { event.preventDefault(); }); - var listener2 = sinon.stub(); - var listenerDefault = sinon.stub(); + let listener2 = sinon.stub(); + let listenerDefault = sinon.stub(); this.emitter.setShouldUseFacade(true); this.emitter.on('event', listenerDefault, true); @@ -494,7 +496,7 @@ describe('EventEmitter', function() { }); it('should remove all listeners on dispose', function() { - var listener = sinon.stub(); + let listener = sinon.stub(); this.emitter.on('event', listener); this.emitter.dispose(); diff --git a/packages/metal-events/test/EventEmitterProxy.js b/packages/metal-events/test/EventEmitterProxy.js index 232f7d7e..2099bd82 100644 --- a/packages/metal-events/test/EventEmitterProxy.js +++ b/packages/metal-events/test/EventEmitterProxy.js @@ -5,11 +5,11 @@ import EventEmitterProxy from '../src/EventEmitterProxy'; describe('EventEmitterProxy', function() { it('should proxy event from origin to target', function() { - var origin = new EventEmitter(); - var target = new EventEmitter(); + let origin = new EventEmitter(); + let target = new EventEmitter(); new EventEmitterProxy(origin, target); - var listener = sinon.stub(); + let listener = sinon.stub(); target.on('event1', listener); origin.emit('event1', 1, 2); @@ -19,13 +19,13 @@ describe('EventEmitterProxy', function() { }); it('should not proxy blacklisted event', function() { - var origin = new EventEmitter(); - var target = new EventEmitter(); + let origin = new EventEmitter(); + let target = new EventEmitter(); new EventEmitterProxy(origin, target, { - event1: true + event1: true, }); - var listener = sinon.stub(); + let listener = sinon.stub(); target.on('event1', listener); origin.emit('event1', 1, 2); @@ -33,13 +33,13 @@ describe('EventEmitterProxy', function() { }); it('should proxy only whitelisted events', function() { - var origin = new EventEmitter(); - var target = new EventEmitter(); + let origin = new EventEmitter(); + let target = new EventEmitter(); new EventEmitterProxy(origin, target, null, { - event1: true + event1: true, }); - var listener = sinon.stub(); + let listener = sinon.stub(); target.on('event1', listener); target.on('event2', listener); origin.emit('event1', 1, 2); @@ -49,15 +49,20 @@ describe('EventEmitterProxy', function() { }); it('should not proxy event that is both whitelisted and blacklisted', function() { - var origin = new EventEmitter(); - var target = new EventEmitter(); - new EventEmitterProxy(origin, target, { - event1: true - }, { - event1: true - }); - - var listener = sinon.stub(); + let origin = new EventEmitter(); + let target = new EventEmitter(); + new EventEmitterProxy( + origin, + target, + { + event1: true, + }, + { + event1: true, + } + ); + + let listener = sinon.stub(); target.on('event1', listener); target.on('event2', listener); origin.emit('event1', 1, 2); @@ -67,13 +72,13 @@ describe('EventEmitterProxy', function() { }); it('should only emit proxied event once per listener', function() { - var origin = new EventEmitter(); - var target = new EventEmitter(); + let origin = new EventEmitter(); + let target = new EventEmitter(); new EventEmitterProxy(origin, target); - var listener1 = sinon.stub(); + let listener1 = sinon.stub(); target.on('event1', listener1); - var listener2 = sinon.stub(); + let listener2 = sinon.stub(); target.on('event1', listener2); origin.emit('event1', 1, 2); @@ -82,14 +87,14 @@ describe('EventEmitterProxy', function() { }); it('should change the emitter that events are proxied from', function() { - var origin = new EventEmitter(); - var target = new EventEmitter(); - var proxy = new EventEmitterProxy(origin, target); + let origin = new EventEmitter(); + let target = new EventEmitter(); + let proxy = new EventEmitterProxy(origin, target); - var listener = sinon.stub(); + let listener = sinon.stub(); target.on('event1', listener); - var origin2 = new EventEmitter(); + let origin2 = new EventEmitter(); proxy.setOriginEmitter(origin2); origin.emit('event1', 1, 2); @@ -102,13 +107,13 @@ describe('EventEmitterProxy', function() { }); it('should remove listeners after changing the emitter that events were proxied from', function() { - var target = new EventEmitter(); - var proxy = new EventEmitterProxy(new EventEmitter(), target); + let target = new EventEmitter(); + let proxy = new EventEmitterProxy(new EventEmitter(), target); - var listener = sinon.stub(); + let listener = sinon.stub(); target.on('event1', listener); - var origin2 = new EventEmitter(); + let origin2 = new EventEmitter(); proxy.setOriginEmitter(origin2); proxy.dispose(); @@ -117,27 +122,27 @@ describe('EventEmitterProxy', function() { }); it('should not throw error if origin emitter is set to null', function() { - var origin = new EventEmitter(); - var target = new EventEmitter(); - var proxy = new EventEmitterProxy(origin, target); + let origin = new EventEmitter(); + let target = new EventEmitter(); + let proxy = new EventEmitterProxy(origin, target); - var listener = sinon.stub(); + let listener = sinon.stub(); target.on('event1', listener); assert.doesNotThrow(() => proxy.setOriginEmitter(null)); }); it('should pass proxied events to new origin emitters, even when no emitter exists for a while', function() { - var origin = new EventEmitter(); - var target = new EventEmitter(); - var proxy = new EventEmitterProxy(origin, target); + let origin = new EventEmitter(); + let target = new EventEmitter(); + let proxy = new EventEmitterProxy(origin, target); - var listener = sinon.stub(); + let listener = sinon.stub(); target.on('event1', listener); proxy.setOriginEmitter(null); - var origin2 = new EventEmitter(); + let origin2 = new EventEmitter(); proxy.setOriginEmitter(origin2); origin.emit('event1', 1, 2); @@ -150,13 +155,13 @@ describe('EventEmitterProxy', function() { }); it('should allow manually choosing events to be proxied', function() { - var origin = new EventEmitter(); - var target = new EventEmitter(); + let origin = new EventEmitter(); + let target = new EventEmitter(); - var listener = sinon.stub(); + let listener = sinon.stub(); target.on('event1', listener); - var proxy = new EventEmitterProxy(origin, target); + let proxy = new EventEmitterProxy(origin, target); proxy.proxyEvent('event1'); origin.emit('event1', 1, 2); @@ -166,11 +171,11 @@ describe('EventEmitterProxy', function() { }); it('should not proxy events after disposed', function() { - var origin = new EventEmitter(); - var target = new EventEmitter(); - var proxy = new EventEmitterProxy(origin, target); + let origin = new EventEmitter(); + let target = new EventEmitter(); + let proxy = new EventEmitterProxy(origin, target); - var listener = sinon.stub(); + let listener = sinon.stub(); target.on('event1', listener); proxy.dispose(); diff --git a/packages/metal-events/test/EventHandle.js b/packages/metal-events/test/EventHandle.js index 2eb84890..e6baccb3 100644 --- a/packages/metal-events/test/EventHandle.js +++ b/packages/metal-events/test/EventHandle.js @@ -5,9 +5,9 @@ import EventEmitter from '../src/EventEmitter'; describe('EventHandle', function() { it('should unsubscribe the listener', function() { - var emitter = new EventEmitter(); - var listener = sinon.stub(); - var handle = new EventHandle(emitter, 'event', listener); + let emitter = new EventEmitter(); + let listener = sinon.stub(); + let handle = new EventHandle(emitter, 'event', listener); emitter.on('event', listener); emitter.on('event2', listener); @@ -21,18 +21,18 @@ describe('EventHandle', function() { }); it('should not throw error when removing listener on disposed emitter', function() { - var emitter = new EventEmitter(); - var listener = sinon.stub(); - var handle = new EventHandle(emitter, 'event', listener); + let emitter = new EventEmitter(); + let listener = sinon.stub(); + let handle = new EventHandle(emitter, 'event', listener); emitter.dispose(); handle.removeListener(); }); it('should remove listeners when disposed', function() { - var emitter = new EventEmitter(); - var listener = sinon.stub(); - var handle = new EventHandle(emitter, 'event', listener); + let emitter = new EventEmitter(); + let listener = sinon.stub(); + let handle = new EventHandle(emitter, 'event', listener); emitter.on('event', listener); handle.dispose(); emitter.emit('event'); diff --git a/packages/metal-events/test/EventHandler.js b/packages/metal-events/test/EventHandler.js index 19a84e10..a7a7b893 100644 --- a/packages/metal-events/test/EventHandler.js +++ b/packages/metal-events/test/EventHandler.js @@ -5,11 +5,11 @@ import EventHandler from '../src/EventHandler'; describe('EventHandler', function() { it('should remove all added listeners', function() { - var emitter1 = new EventEmitter(); - var emitter2 = new EventEmitter(); - var handler = new EventHandler(); - var listener1 = sinon.stub(); - var listener2 = sinon.stub(); + let emitter1 = new EventEmitter(); + let emitter2 = new EventEmitter(); + let handler = new EventHandler(); + let listener1 = sinon.stub(); + let listener2 = sinon.stub(); handler.add( emitter1.on('event1', listener1), @@ -43,9 +43,9 @@ describe('EventHandler', function() { }); it('should clear listeners on dispose', function() { - var emitter = new EventEmitter(); - var handler = new EventHandler(); - var listener = sinon.stub(); + let emitter = new EventEmitter(); + let handler = new EventHandler(); + let listener = sinon.stub(); handler.add(emitter.on('event', listener)); handler.dispose(); diff --git a/packages/metal-incremental-dom/.eslintrc b/packages/metal-incremental-dom/.eslintrc new file mode 100644 index 00000000..8ea512bf --- /dev/null +++ b/packages/metal-incremental-dom/.eslintrc @@ -0,0 +1,9 @@ +{ + "globals": { + "IncrementalDOM": true + }, + "rules": { + "prefer-rest-params": 0, + "require-jsdoc": 0 + } +} diff --git a/packages/metal-incremental-dom/package-lock.json b/packages/metal-incremental-dom/package-lock.json index fd905d11..84282c1e 100644 --- a/packages/metal-incremental-dom/package-lock.json +++ b/packages/metal-incremental-dom/package-lock.json @@ -64,7 +64,7 @@ "lodash": "4.17.4", "minimatch": "3.0.4", "path-is-absolute": "1.0.1", - "private": "0.1.7", + "private": "0.1.8", "slash": "1.0.0", "source-map": "0.5.7" } @@ -507,9 +507,9 @@ } }, "babel-preset-env": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/babel-preset-env/-/babel-preset-env-1.6.0.tgz", - "integrity": "sha512-OVgtQRuOZKckrILgMA5rvctvFZPv72Gua9Rt006AiPoB0DJKGN07UmaQA+qRrYgK71MVct8fFhT0EyNWYorVew==", + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/babel-preset-env/-/babel-preset-env-1.6.1.tgz", + "integrity": "sha512-W6VIyA6Ch9ePMI7VptNn2wBM6dbG0eSz25HEiL40nQXCsXGTGZSTZu1Iap+cj3Q0S5a7T9+529l/5Bkvd+afNA==", "requires": { "babel-plugin-check-es2015-constants": "6.22.0", "babel-plugin-syntax-trailing-function-commas": "6.22.0", @@ -538,7 +538,7 @@ "babel-plugin-transform-es2015-unicode-regex": "6.24.1", "babel-plugin-transform-exponentiation-operator": "6.24.1", "babel-plugin-transform-regenerator": "6.26.0", - "browserslist": "2.5.1", + "browserslist": "2.8.0", "invariant": "2.2.2", "semver": "5.4.1" } @@ -625,18 +625,18 @@ } }, "browserslist": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-2.5.1.tgz", - "integrity": "sha512-jAvM2ku7YDJ+leAq3bFH1DE0Ylw+F+EQDq4GkqZfgPEqpWYw9ofQH85uKSB9r3Tv7XDbfqVtE+sdvKJW7IlPJA==", + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-2.8.0.tgz", + "integrity": "sha512-iiWHM1Et6Q4TQpB7Ar6pxuM3TNMXasVJY4Y/oh3q38EwR3Z+IdZ9MyVf7PI4MJFB4xpwMcZgs9bEUnPG2E3TCA==", "requires": { - "caniuse-lite": "1.0.30000746", - "electron-to-chromium": "1.3.25" + "caniuse-lite": "1.0.30000760", + "electron-to-chromium": "1.3.27" } }, "caniuse-lite": { - "version": "1.0.30000746", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000746.tgz", - "integrity": "sha1-xk+Vo5Jc/TAgejCO12wa6W6gnqA=" + "version": "1.0.30000760", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000760.tgz", + "integrity": "sha1-7HIDlXQvHH7IlH/W3SYE53qPmP8=" }, "chalk": { "version": "1.1.3", @@ -687,9 +687,9 @@ } }, "electron-to-chromium": { - "version": "1.3.25", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.25.tgz", - "integrity": "sha1-RTshAJg20Jl9hgNWAf9srkeRxGA=" + "version": "1.3.27", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.27.tgz", + "integrity": "sha1-eOy4o5kGYYe7N07t412ccFZagD0=" }, "escape-string-regexp": { "version": "1.0.5", @@ -889,9 +889,9 @@ "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" }, "private": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/private/-/private-0.1.7.tgz", - "integrity": "sha1-aM5eih7woju1cMwoU3tTMqumPvE=" + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/private/-/private-0.1.8.tgz", + "integrity": "sha512-VvivMrbvd2nKkiG38qjULzlc+4Vx4wm/whI9pQD35YrARNnhxeiRktSOhSukRLFNlzg6Br/cJPet5J/u19r/mg==" }, "regenerate": { "version": "1.3.3", @@ -910,7 +910,7 @@ "requires": { "babel-runtime": "6.26.0", "babel-types": "6.26.0", - "private": "0.1.7" + "private": "0.1.8" } }, "regexpu-core": { diff --git a/packages/metal-incremental-dom/src/IncrementalDomRenderer.js b/packages/metal-incremental-dom/src/IncrementalDomRenderer.js index 969f26a4..7f11b85a 100644 --- a/packages/metal-incremental-dom/src/IncrementalDomRenderer.js +++ b/packages/metal-incremental-dom/src/IncrementalDomRenderer.js @@ -1,12 +1,12 @@ 'use strict'; import './incremental-dom'; -import { getChanges, trackChanges } from './changes'; -import { clearData, getData } from './data'; -import { getOwner } from './children/children'; -import { getPatchingComponent, patch } from './render/patch'; -import { render, renderChild, renderFunction } from './render/render'; -import { Component, ComponentRenderer } from 'metal-component'; +import {getChanges, trackChanges} from './changes'; +import {clearData, getData} from './data'; +import {getOwner} from './children/children'; +import {getPatchingComponent, patch} from './render/patch'; +import {render, renderChild, renderFunction} from './render/render'; +import {Component, ComponentRenderer} from 'metal-component'; class IncrementalDomRenderer extends ComponentRenderer.constructor { /** @@ -110,19 +110,18 @@ class IncrementalDomRenderer extends ComponentRenderer.constructor { * through incremental dom function calls. If the first arg is a function * instead of a component instance, creates and renders this function, which * can either be a simple incremental dom function or a component constructor. - * @param {!Component} component * @param {!Component|function()} component Can be a component instance, a * simple incremental dom function or a component constructor. - * @param {Object|Element=} opt_dataOrElement Optional config data for the + * @param {Object|Element=} dataOrElement Optional config data for the * function, or parent for the rendered content. - * @param {Element=} opt_parent Optional parent for the rendered content. + * @param {Element=} parent Optional parent for the rendered content. * @return {!Component} The rendered component's instance. */ - render(component, opt_dataOrElement, opt_parent) { + render(component, dataOrElement, parent) { if (component instanceof Component) { this.patch(component); } else { - return renderFunction(this, component, opt_dataOrElement, opt_parent); + return renderFunction(this, component, dataOrElement, parent); } } @@ -156,7 +155,8 @@ class IncrementalDomRenderer extends ComponentRenderer.constructor { renderInsidePatch(component) { const changes = getChanges(component); - const shouldRender = !component.wasRendered || + const shouldRender = + !component.wasRendered || this.shouldUpdate(component, changes) || IncrementalDOM.currentPointer() !== component.element; if (shouldRender) { @@ -193,7 +193,7 @@ class IncrementalDomRenderer extends ComponentRenderer.constructor { return false; } if (component.shouldUpdate) { - return component.shouldUpdate(...this.buildShouldUpdateArgs(changes)); + return component.shouldUpdate(...this.buildShouldUpdateArgs(changes)); // eslint-disable-line } return true; } diff --git a/packages/metal-incremental-dom/src/all/incremental-dom.js b/packages/metal-incremental-dom/src/all/incremental-dom.js index 98b699d5..e2d8cc14 100644 --- a/packages/metal-incremental-dom/src/all/incremental-dom.js +++ b/packages/metal-incremental-dom/src/all/incremental-dom.js @@ -1,5 +1,5 @@ import HTML2IncDom from '../html/HTML2IncDom'; import IncrementalDomRenderer from '../IncrementalDomRenderer'; -export { HTML2IncDom }; +export {HTML2IncDom}; export default IncrementalDomRenderer; diff --git a/packages/metal-incremental-dom/src/changes.js b/packages/metal-incremental-dom/src/changes.js index d26b3ec7..829e6e5c 100644 --- a/packages/metal-incremental-dom/src/changes.js +++ b/packages/metal-incremental-dom/src/changes.js @@ -1,6 +1,6 @@ 'use strict'; -import { getData } from './data'; +import {getData} from './data'; /** * Clears the changes tracked so far. diff --git a/packages/metal-incremental-dom/src/children/children.js b/packages/metal-incremental-dom/src/children/children.js index 73420033..8369a5fa 100644 --- a/packages/metal-incremental-dom/src/children/children.js +++ b/packages/metal-incremental-dom/src/children/children.js @@ -1,8 +1,8 @@ 'use strict'; -import { buildCallFromConfig, buildConfigFromCall } from '../callArgs'; -import { isDef } from 'metal'; -import { startInterception, stopInterception } from '../incremental-dom-aop'; +import {buildCallFromConfig, buildConfigFromCall} from '../callArgs'; +import {isDef} from 'metal'; +import {startInterception, stopInterception} from '../incremental-dom-aop'; /** * Property identifying a specific object as a Metal.js child node, and @@ -24,8 +24,8 @@ export function captureChildren(component, callback, data) { callbackData_ = data; tree_ = { props: { - children: [] - } + children: [], + }, }; tree_.config = tree_.props; currentParent_ = tree_; @@ -33,7 +33,7 @@ export function captureChildren(component, callback, data) { startInterception({ elementClose: handleInterceptedCloseCall_, elementOpen: handleInterceptedOpenCall_, - text: handleInterceptedTextCall_ + text: handleInterceptedTextCall_, }); } @@ -57,19 +57,19 @@ export function getOwner(node) { /** * Renders a children tree through incremental dom. - * @param {!{args: Array, children: !Array, isText: ?boolean}} - * @param {function()=} opt_skipNode Optional function that is called for + * @param {!{args: Array, children: !Array, isText: ?boolean}} tree + * @param {function()=} skipNode Optional function that is called for * each node to be rendered. If it returns true, the node will be skipped. * @protected */ -export function renderChildTree(tree, opt_skipNode) { +export function renderChildTree(tree, skipNode) { if (isCapturing_) { // If capturing, just add the node directly to the captured tree. addChildToTree(tree); return; } - if (opt_skipNode && opt_skipNode.call(null, tree)) { + if (skipNode && skipNode.call(null, tree)) { return; } @@ -81,12 +81,12 @@ export function renderChildTree(tree, opt_skipNode) { let args = buildCallFromConfig(tree.tag, tree.props); args[0] = { tag: args[0], - owner: getOwner(tree) + owner: getOwner(tree), }; IncrementalDOM.elementOpen.apply(null, args); if (tree.props.children) { for (let i = 0; i < tree.props.children.length; i++) { - renderChildTree(tree.props.children[i], opt_skipNode); + renderChildTree(tree.props.children[i], skipNode); } } IncrementalDOM.elementClose(tree.tag); @@ -103,17 +103,18 @@ let tree_; /** * Adds a child element to the tree. * @param {!Array} args The arguments passed to the incremental dom call. - * @param {boolean=} opt_isText Optional flag indicating if the child is a + * @param {boolean=} isText Optional flag indicating if the child is a * text element. * @protected + * @return {Object} */ -function addChildCallToTree_(args, opt_isText) { +function addChildCallToTree_(args, isText = false) { const child = { parent: currentParent_, - [CHILD_OWNER]: owner_ + [CHILD_OWNER]: owner_, }; - if (opt_isText) { + if (isText) { child.text = args[0]; if (args.length > 1) { child.args = args; @@ -137,6 +138,7 @@ function addChildToTree(child) { * Handles an intercepted call to the `elementClose` function from incremental * dom. * @protected + * @return {Element | boolean} */ function handleInterceptedCloseCall_() { if (currentParent_ === tree_) { diff --git a/packages/metal-incremental-dom/src/cleanup/unused.js b/packages/metal-incremental-dom/src/cleanup/unused.js index ecb07801..6489a6d3 100644 --- a/packages/metal-incremental-dom/src/cleanup/unused.js +++ b/packages/metal-incremental-dom/src/cleanup/unused.js @@ -1,6 +1,6 @@ 'use strict'; -import { getData } from '../data'; +import {getData} from '../data'; let comps_ = []; let disposing_ = false; diff --git a/packages/metal-incremental-dom/src/html/HTML2IncDom.js b/packages/metal-incremental-dom/src/html/HTML2IncDom.js index 8b1004d3..e478db5e 100644 --- a/packages/metal-incremental-dom/src/html/HTML2IncDom.js +++ b/packages/metal-incremental-dom/src/html/HTML2IncDom.js @@ -3,7 +3,7 @@ import HTMLParser from './HTMLParser'; import unescape from './unescape'; -var parser_; +let parser_; class HTML2IncDom { /** @@ -32,16 +32,14 @@ class HTML2IncDom { static run(html) { HTML2IncDom.getParser()(html, { start: function(tag, attrs, unary) { - var fn = unary ? IncrementalDOM.elementVoid : IncrementalDOM.elementOpen; - var args = [ - tag, - null, - [] - ]; - for (var i = 0; i < attrs.length; i++) { + let fn = unary + ? IncrementalDOM.elementVoid + : IncrementalDOM.elementOpen; + let args = [tag, null, []]; + for (let i = 0; i < attrs.length; i++) { args.push(attrs[i].name, attrs[i].value); } - fn.apply(null, args); + fn(...args); }, end: function(tag) { @@ -50,7 +48,7 @@ class HTML2IncDom { chars: function(text) { IncrementalDOM.text(text, unescape); - } + }, }); } @@ -61,7 +59,7 @@ class HTML2IncDom { * any function that follows that same api, basically accepting the html * string and an object with `start`, `end` and `chars` functions to be called * during the parsing. - * @param {!function(string, !Object} newParser + * @param {!function(string, !Object)} newParser */ static setParser(newParser) { parser_ = newParser; diff --git a/packages/metal-incremental-dom/src/html/HTMLParser.js b/packages/metal-incremental-dom/src/html/HTMLParser.js index 0cb0aeb5..bff74390 100644 --- a/packages/metal-incremental-dom/src/html/HTMLParser.js +++ b/packages/metal-incremental-dom/src/html/HTMLParser.js @@ -91,27 +91,39 @@ var startTag = /^<([-A-Za-z0-9_]+)((?:\s+[a-zA-Z_:][-a-zA-Z0-9_:.]*(?:\s*=\s*(?: attr = /([a-zA-Z_:][-a-zA-Z0-9_:.]*)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|([^>\s]+)))?/g; // Empty Elements - HTML 5 -var empty = makeMap("area,base,basefont,br,col,frame,hr,img,input,link,meta,param,embed,command,keygen,source,track,wbr"); +var empty = makeMap( + 'area,base,basefont,br,col,frame,hr,img,input,link,meta,param,embed,command,keygen,source,track,wbr' +); // Block Elements - HTML 5 -var block = makeMap("a,address,article,applet,aside,audio,blockquote,button,canvas,center,dd,del,dir,div,dl,dt,fieldset,figcaption,figure,footer,form,frameset,h1,h2,h3,h4,h5,h6,header,hgroup,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,output,p,pre,section,script,table,tbody,td,tfoot,th,thead,tr,ul,video"); +var block = makeMap( + 'a,address,article,applet,aside,audio,blockquote,button,canvas,center,dd,del,dir,div,dl,dt,fieldset,figcaption,figure,footer,form,frameset,h1,h2,h3,h4,h5,h6,header,hgroup,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,output,p,pre,section,script,table,tbody,td,tfoot,th,thead,tr,ul,video' +); // Inline Elements - HTML 5 -var inline = makeMap("abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var"); +var inline = makeMap( + 'abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var' +); // Elements that you can, intentionally, leave open // (and which close themselves) -var closeSelf = makeMap("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr"); +var closeSelf = makeMap('colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr'); // Attributes that have their values filled in disabled="disabled" -var fillAttrs = makeMap("checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected"); +var fillAttrs = makeMap( + 'checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected' +); // Special Elements (can contain anything) -var special = makeMap("script,style"); +var special = makeMap('script,style'); -var HTMLParser = function (html, handler) { - var index, chars, match, stack = [], last = html; - stack.last = function () { +var HTMLParser = function(html, handler) { + var index, + chars, + match, + stack = [], + last = html; + stack.last = function() { return this[this.length - 1]; }; @@ -120,20 +132,18 @@ var HTMLParser = function (html, handler) { // Make sure we're not in a script or style element if (!stack.last() || !special[stack.last()]) { - // Comment - if (html.indexOf(""); + if (html.indexOf(''); if (index >= 0) { - if (handler.comment) - handler.comment(html.substring(4, index)); + if (handler.comment) handler.comment(html.substring(4, index)); html = html.substring(index + 3); chars = false; } // end tag - } else if (html.indexOf("]*>"), function (all, text) { - text = text.replace(/|/g, "$1$2"); - if (handler.chars) - handler.chars(text); - - return ""; - }); + html = html.replace( + new RegExp('([\\s\\S]*?)]*>'), + function(all, text) { + text = text.replace( + /|/g, + '$1$2' + ); + if (handler.chars) handler.chars(text); + + return ''; + } + ); - parseEndTag("", stack.last()); + parseEndTag('', stack.last()); } - if (html == last) - throw "Parse Error: " + html; + if (html == last) throw 'Parse Error: ' + html; last = html; } @@ -192,56 +204,51 @@ var HTMLParser = function (html, handler) { // Note: this exception for "span" was added manually (i.e. it's not // present in the original code). while (stack.last() && inline[stack.last()] && stack.last() !== 'span') { - parseEndTag("", stack.last()); + parseEndTag('', stack.last()); } } if (closeSelf[tagName] && stack.last() == tagName) { - parseEndTag("", tagName); + parseEndTag('', tagName); } unary = empty[tagName] || !!unary; - if (!unary) - stack.push(tagName); + if (!unary) stack.push(tagName); if (handler.start) { var attrs = []; - rest.replace(attr, function (match, name) { - var value = arguments[2] ? arguments[2] : - arguments[3] ? arguments[3] : - arguments[4] ? arguments[4] : - fillAttrs[name] ? name : ""; + rest.replace(attr, function(match, name) { + var value = arguments[2] + ? arguments[2] + : arguments[3] + ? arguments[3] + : arguments[4] ? arguments[4] : fillAttrs[name] ? name : ''; attrs.push({ name: name, value: value, - escaped: value.replace(/(^|[^\\])"/g, '$1\\\"') //" + escaped: value.replace(/(^|[^\\])"/g, '$1\\"') //" }); }); - if (handler.start) - handler.start(tagName, attrs, unary); + if (handler.start) handler.start(tagName, attrs, unary); } } function parseEndTag(tag, tagName) { // If no tag name is provided, clean shop - if (!tagName) - var pos = 0; - - // Find the closest opened tag of the same type + if (!tagName) var pos = 0; else + // Find the closest opened tag of the same type for (var pos = stack.length - 1; pos >= 0; pos--) - if (stack[pos] == tagName) - break; + if (stack[pos] == tagName) break; if (pos >= 0) { // Close all the open elements, up the stack for (var i = stack.length - 1; i >= pos; i--) - if (handler.end) - handler.end(stack[i]); + if (handler.end) handler.end(stack[i]); // Remove the open elements from the stack stack.length = pos; @@ -250,9 +257,9 @@ var HTMLParser = function (html, handler) { }; function makeMap(str) { - var obj = {}, items = str.split(","); - for (var i = 0; i < items.length; i++) - obj[items[i]] = true; + var obj = {}, + items = str.split(','); + for (var i = 0; i < items.length; i++) obj[items[i]] = true; return obj; } diff --git a/packages/metal-incremental-dom/src/html/unescape.js b/packages/metal-incremental-dom/src/html/unescape.js index 347eb9eb..1bc28b61 100644 --- a/packages/metal-incremental-dom/src/html/unescape.js +++ b/packages/metal-incremental-dom/src/html/unescape.js @@ -21,43 +21,43 @@ * @param {string} str The string to unescape. * @return {string} The unescaped {@code str} string. */ - function unescape(str) { - /** @type {!Object} */ - var seen = {'&': '&', '<': '<', '>': '>', '"': '"'}; - var div = document.createElement('div'); +function unescape(str) { + /** @type {!Object} */ + let seen = {'&': '&', '<': '<', '>': '>', '"': '"'}; + let div = document.createElement('div'); - // Match as many valid entity characters as possible. If the actual entity - // happens to be shorter, it will still work as innerHTML will return the - // trailing characters unchanged. Since the entity characters do not include - // open angle bracket, there is no chance of XSS from the innerHTML use. - // Since no whitespace is passed to innerHTML, whitespace is preserved. - return str.replace(HTML_ENTITY_PATTERN_, function(s, entity) { - // Check for cached entity. - var value = seen[s]; - if (value) { - return value; - } - // Check for numeric entity. - if (entity.charAt(0) === '#') { - // Prefix with 0 so that hex entities (e.g. ) parse as hex numbers. - var n = Number('0' + entity.substr(1)); - if (!isNaN(n)) { - value = String.fromCharCode(n); - } - } - // Fall back to innerHTML otherwise. - if (!value) { - // Append a non-entity character to avoid a bug in Webkit that parses - // an invalid entity at the end of innerHTML text as the empty string. - div.innerHTML = s + ' '; - // Then remove the trailing character from the result. - value = div.firstChild.nodeValue.slice(0, -1); - } - // Cache and return. - seen[s] = value; - return value; - }); - } + // Match as many valid entity characters as possible. If the actual entity + // happens to be shorter, it will still work as innerHTML will return the + // trailing characters unchanged. Since the entity characters do not include + // open angle bracket, there is no chance of XSS from the innerHTML use. + // Since no whitespace is passed to innerHTML, whitespace is preserved. + return str.replace(HTML_ENTITY_PATTERN_, function(s, entity) { + // Check for cached entity. + let value = seen[s]; + if (value) { + return value; + } + // Check for numeric entity. + if (entity.charAt(0) === '#') { + // Prefix with 0 so that hex entities (e.g. ) parse as hex numbers. + let n = Number('0' + entity.substr(1)); + if (!isNaN(n)) { + value = String.fromCharCode(n); + } + } + // Fall back to innerHTML otherwise. + if (!value) { + // Append a non-entity character to avoid a bug in Webkit that parses + // an invalid entity at the end of innerHTML text as the empty string. + div.innerHTML = s + ' '; + // Then remove the trailing character from the result. + value = div.firstChild.nodeValue.slice(0, -1); + } + // Cache and return. + seen[s] = value; + return value; + }); +} export default unescape; @@ -65,4 +65,4 @@ export default unescape; * Regular expression that matches an HTML entity. * @type {!RegExp} */ -var HTML_ENTITY_PATTERN_ = /&([^;\s<&]+);?/g; +const HTML_ENTITY_PATTERN_ = /&([^;\s<&]+);?/g; diff --git a/packages/metal-incremental-dom/src/incremental-dom-aop.js b/packages/metal-incremental-dom/src/incremental-dom-aop.js index bed50f39..b01bf5c3 100644 --- a/packages/metal-incremental-dom/src/incremental-dom-aop.js +++ b/packages/metal-incremental-dom/src/incremental-dom-aop.js @@ -55,7 +55,7 @@ const originalFns = { elementOpenEnd: IncrementalDOM.elementOpenEnd, elementOpenStart: IncrementalDOM.elementOpenStart, elementVoid: IncrementalDOM.elementVoid, - text: IncrementalDOM.text + text: IncrementalDOM.text, }; const fnStack = []; @@ -85,7 +85,7 @@ function getStack() { function buildHandleCall(name) { const data = { - name + name, }; const fn = handleCall.bind(data); return fn; @@ -95,7 +95,7 @@ function handleCall() { const name = this.name; // eslint-disable-line const stack = getStack(); const fn = (stack && stack[name]) || originalFns[name]; - return fn.apply(null, arguments); + return fn(...arguments); } IncrementalDOM.attr = buildHandleCall('attr'); diff --git a/packages/metal-incremental-dom/src/incremental-dom.js b/packages/metal-incremental-dom/src/incremental-dom.js index f476f793..c8cc54d5 100644 --- a/packages/metal-incremental-dom/src/incremental-dom.js +++ b/packages/metal-incremental-dom/src/incremental-dom.js @@ -1,6 +1,6 @@ import * as IncrementalDOM from 'incremental-dom'; import * as IncrementalDOMString from 'incremental-dom-string'; -import { isServerSide } from 'metal'; +import {isServerSide} from 'metal'; if (isServerSide()) { // Overrides global.IncrementalDOM virtual elements with incremental dom @@ -9,7 +9,10 @@ if (isServerSide()) { // browser. global.IncrementalDOM = IncrementalDOMString; } else { - var scope = (typeof exports !== 'undefined' && typeof global !== 'undefined') ? global : window; + let scope = + typeof exports !== 'undefined' && typeof global !== 'undefined' + ? global + : window; - scope.IncrementalDOM = IncrementalDOM; + scope.IncrementalDOM = IncrementalDOM; } diff --git a/packages/metal-incremental-dom/src/intercept.js b/packages/metal-incremental-dom/src/intercept.js index cc8ebee9..b7bcc8a5 100644 --- a/packages/metal-incremental-dom/src/intercept.js +++ b/packages/metal-incremental-dom/src/intercept.js @@ -66,7 +66,7 @@ const originalFns = { elementOpenEnd: IncrementalDOM.elementOpenEnd, elementOpenStart: IncrementalDOM.elementOpenStart, elementVoid: IncrementalDOM.elementVoid, - text: IncrementalDOM.text + text: IncrementalDOM.text, }; const fnStack = []; @@ -96,7 +96,7 @@ function getStack() { function buildHandleCall(name) { const data = { - name + name, }; const fn = handleCall.bind(data); return fn; @@ -106,7 +106,7 @@ function handleCall() { const name = this.name; // eslint-disable-line const stack = getStack(); const fn = (stack && stack[name]) || originalFns[name]; - return fn.apply(null, arguments); + return fn(...arguments); } IncrementalDOM.attr = buildHandleCall('attr'); diff --git a/packages/metal-incremental-dom/src/render/attributes.js b/packages/metal-incremental-dom/src/render/attributes.js index c4c94a7e..cc78f14e 100644 --- a/packages/metal-incremental-dom/src/render/attributes.js +++ b/packages/metal-incremental-dom/src/render/attributes.js @@ -1,10 +1,10 @@ 'use strict'; -import { isServerSide } from 'metal'; -import { delegate } from 'metal-dom'; -import { getComponentFn } from 'metal-component'; -import { getOriginalFn } from '../incremental-dom-aop'; -import { isBoolean, isDefAndNotNull, isString } from 'metal'; +import {isServerSide} from 'metal'; +import {delegate} from 'metal-dom'; +import {getComponentFn} from 'metal-component'; +import {getOriginalFn} from '../incremental-dom-aop'; +import {isBoolean, isDefAndNotNull, isString} from 'metal'; const HANDLE_SUFFIX = '__handle__'; const LISTENER_REGEX = /^(?:on([A-Z].+))|(?:data-on(.+))$/; diff --git a/packages/metal-incremental-dom/src/render/patch.js b/packages/metal-incremental-dom/src/render/patch.js index 942e1557..806837f6 100644 --- a/packages/metal-incremental-dom/src/render/patch.js +++ b/packages/metal-incremental-dom/src/render/patch.js @@ -1,9 +1,9 @@ 'use strict'; -import { append, exitDocument } from 'metal-dom'; -import { getData } from '../data'; -import { isServerSide } from 'metal'; -import { render } from './render'; +import {append, exitDocument} from 'metal-dom'; +import {getData} from '../data'; +import {isServerSide} from 'metal'; +import {render} from './render'; const patchingComponents_ = []; @@ -11,6 +11,7 @@ const patchingComponents_ = []; * Guarantees that the component's element has a parent. That's necessary * when calling incremental dom's `patchOuter` for now, as otherwise it will * throw an error if the element needs to be replaced. + * @param {Element} element * @return {Element} The parent, in case it was added. * @private */ @@ -31,11 +32,11 @@ function buildParentIfNecessary_(element) { * Calls incremental dom's patch function. * @param {!Component} component The component to patch. * @param {!Element} element The element the component should be patched on. - * @param {boolean=} opt_outer Flag indicating if `patchOuter` should be used + * @param {boolean=} outer Flag indicating if `patchOuter` should be used * instead of `patch`. * @private */ -function callPatch_(component, element, opt_outer) { +function callPatch_(component, element, outer) { patchingComponents_.push(component); const data = getData(component); @@ -44,7 +45,7 @@ function callPatch_(component, element, opt_outer) { data.render = render.bind(null, component); } - const patchFn = opt_outer ? IncrementalDOM.patchOuter : IncrementalDOM.patch; + const patchFn = outer ? IncrementalDOM.patchOuter : IncrementalDOM.patch; patchFn(element, data.render); patchingComponents_.pop(); diff --git a/packages/metal-incremental-dom/src/render/render.js b/packages/metal-incremental-dom/src/render/render.js index 3f86e097..0fd3edec 100644 --- a/packages/metal-incremental-dom/src/render/render.js +++ b/packages/metal-incremental-dom/src/render/render.js @@ -1,15 +1,32 @@ 'use strict'; -import { applyAttribute, convertListenerNamesToFns } from './attributes'; -import { buildConfigFromCall, buildCallFromConfig } from '../callArgs'; -import { captureChildren, getOwner, isChildTag, renderChildTree } from '../children/children'; -import { clearChanges } from '../changes'; -import { domData } from 'metal-dom'; -import { getData } from '../data'; -import { getCompatibilityModeData, getUid, isDef, isDefAndNotNull, isFunction, isString, object } from 'metal'; -import { disposeUnused, schedule } from '../cleanup/unused'; -import { getOriginalFn, startInterception, stopInterception } from '../incremental-dom-aop'; -import { Component, ComponentRegistry } from 'metal-component'; +import {applyAttribute, convertListenerNamesToFns} from './attributes'; +import {buildConfigFromCall, buildCallFromConfig} from '../callArgs'; +import { + captureChildren, + getOwner, + isChildTag, + renderChildTree, +} from '../children/children'; +import {clearChanges} from '../changes'; +import {domData} from 'metal-dom'; +import {getData} from '../data'; +import { + getCompatibilityModeData, + getUid, + isDef, + isDefAndNotNull, + isFunction, + isString, + object, +} from 'metal'; +import {disposeUnused, schedule} from '../cleanup/unused'; +import { + getOriginalFn, + startInterception, + stopInterception, +} from '../incremental-dom-aop'; +import {Component, ComponentRegistry} from 'metal-component'; const renderingComponents_ = []; const emptyChildren_ = []; @@ -131,7 +148,8 @@ function getRef_(owner, config) { if (compatData) { const ownerRenderer = owner.getRenderer(); const renderers = compatData.renderers; - const useKey = !renderers || + const useKey = + !renderers || renderers.indexOf(ownerRenderer) !== -1 || renderers.indexOf(ownerRenderer.RENDERER_NAME) !== -1; if (useKey && config.key && !config.ref) { @@ -171,7 +189,12 @@ function getSubComponent_(tagOrCtor, config, owner) { data.currCount[type] = data.currCount[type] || 0; key = `__METAL_IC__${type}_${data.currCount[type]++}`; } - comp = match_(data.prevComps ? data.prevComps[key] : null, Ctor, config, owner); + comp = match_( + data.prevComps ? data.prevComps[key] : null, + Ctor, + config, + owner + ); data.currComps = data.currComps || {}; data.currComps[key] = comp; } @@ -183,6 +206,7 @@ function getSubComponent_(tagOrCtor, config, owner) { * Handles the event of children having finished being captured. * @param {!Object} tree The captured children in tree format. * @private + * @return {Object} */ function handleChildrenCaptured_(tree, {props, tag}) { props.children = buildChildren_(tree.props.children); @@ -222,12 +246,13 @@ function handleInterceptedAttributesCall_(element, name, value) { * dom. * @param {string} tag * @private + * @return {Object} */ function handleInterceptedOpenCall_(tag) { if (isComponentTag_(tag)) { - return handleSubComponentCall_.apply(null, arguments); + return handleSubComponentCall_(...arguments); } else { - return handleRegularCall_.apply(null, arguments); + return handleRegularCall_(...arguments); } } @@ -262,7 +287,7 @@ function handleRegularCall_(...args) { convertListenerNamesToFns(comp, config); const call = buildCallFromConfig(tag, config); - const node = getOriginalFn('elementOpen').apply(null, call); + const node = getOriginalFn('elementOpen')(...call); resetNodeData_(node); updateElementIfNotReached_(comp, node); @@ -283,7 +308,7 @@ function handleRegularCall_(...args) { function handleSubComponentCall_(...args) { captureChildren(getComponentBeingRendered(), handleChildrenCaptured_, { props: buildConfigFromCall(args), - tag: args[0] + tag: args[0], }); } @@ -297,7 +322,11 @@ function inheritElementClasses_(parent, config) { const parentData = getData(parent); const parentConfig = parentData.config; - if (!parentData.rootElementReached && parentConfig && isString(parentConfig.elementClasses)) { + if ( + !parentData.rootElementReached && + parentConfig && + isString(parentConfig.elementClasses) + ) { let currentClasses = ''; if (isString(config.elementClasses)) { currentClasses = `${config.elementClasses} `; @@ -314,7 +343,7 @@ function inheritElementClasses_(parent, config) { * @private */ export function isComponentTag_(tag) { - return isFunction(tag) || (isString(tag) && tag[0] === tag[0].toUpperCase()); + return isFunction(tag) || (isString(tag) && tag[0] === tag[0].toUpperCase()); // eslint-disable-line } /** @@ -377,7 +406,7 @@ function prepareRender_(component) { startInterception({ attributes: handleInterceptedAttributesCall_, - elementOpen: handleInterceptedOpenCall_ + elementOpen: handleInterceptedOpenCall_, }); } @@ -424,12 +453,13 @@ export function renderChild(child) { * Renders the contents for the given tag. * @param {!function()|string} tag * @param {!Object} config - * @param {Component=} opt_owner + * @param {Component=} owner * @private + * @return {Object} */ -function renderFromTag_(tag, config, opt_owner) { +function renderFromTag_(tag, config, owner) { if (isString(tag) || tag.prototype.getRenderer) { - const comp = renderSubComponent_(tag, config, opt_owner); + const comp = renderSubComponent_(tag, config, owner); updateElementIfNotReached_(getComponentBeingRendered(), comp.element); return comp.element; } else { @@ -443,12 +473,12 @@ function renderFromTag_(tag, config, opt_owner) { * @param {!IncrementalDomRenderer} renderer * @param {!function()} fnOrCtor Either a simple incremental dom function or a * component constructor. - * @param {Object|Element=} opt_dataOrElement Optional config data for the + * @param {Object|Element=} dataOrElement Optional config data for the * function or parent for the rendered content. - * @param {Element=} opt_parent Optional parent for the rendered content. + * @param {Element=} parent Optional parent for the rendered content. * @return {!Component} The rendered component's instance. */ -export function renderFunction(renderer, fnOrCtor, opt_dataOrElement, opt_parent) { +export function renderFunction(renderer, fnOrCtor, dataOrElement, parent) { if (!Component.isComponentCtor(fnOrCtor)) { const fn = fnOrCtor; class TempComponent extends Component { @@ -466,7 +496,7 @@ export function renderFunction(renderer, fnOrCtor, opt_dataOrElement, opt_parent TempComponent.RENDERER = renderer; fnOrCtor = TempComponent; } - return Component.render(fnOrCtor, opt_dataOrElement, opt_parent); + return Component.render(fnOrCtor, dataOrElement, parent); } /** @@ -476,15 +506,15 @@ export function renderFunction(renderer, fnOrCtor, opt_dataOrElement, opt_parent * updated instead. * @param {string|!function()} tagOrCtor The tag name or constructor function. * @param {!Object} config The config object for the sub component. - * @param {ComponentRenderer=} opt_owner + * @param {ComponentRenderer=} owner * @return {!Component} The updated sub component. * @private */ -function renderSubComponent_(tagOrCtor, config, opt_owner) { +function renderSubComponent_(tagOrCtor, config, owner) { const parent = getComponentBeingRendered(); - const owner = opt_owner || parent; + owner = owner || parent; - inheritElementClasses_(parent, config) + inheritElementClasses_(parent, config); const comp = getSubComponent_(tagOrCtor, config, owner); updateContext_(comp, parent); @@ -533,11 +563,12 @@ function resetNodeData_(node) { * Updates the given component's context according to the data from the * component that is currently being rendered. * @param {!Component} comp + * @param {!Component} parent * @protected */ function updateContext_(comp, parent) { const context = comp.context; - const childContext = parent.getChildContext ? parent.getChildContext() : null; + const childContext = parent.getChildContext ? parent.getChildContext() : null; // eslint-disable-line object.mixin(context, parent.context, childContext); comp.context = context; } diff --git a/packages/metal-incremental-dom/test/.eslintrc b/packages/metal-incremental-dom/test/.eslintrc new file mode 100644 index 00000000..790a71ae --- /dev/null +++ b/packages/metal-incremental-dom/test/.eslintrc @@ -0,0 +1,16 @@ +{ + "env": { + "mocha": true + }, + "globals": { + "after": true, + "assert": true, + "before": true, + "sinon": true + }, + "rules": { + "max-len": 0, + "no-invalid-this": 0, + "require-jsdoc": 0 + } +} \ No newline at end of file diff --git a/packages/metal-incremental-dom/test/.eslintrc.json b/packages/metal-incremental-dom/test/.eslintrc.json deleted file mode 100644 index be351a25..00000000 --- a/packages/metal-incremental-dom/test/.eslintrc.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "env": { - "mocha": true - }, - "globals": { - "assert": true, - "sinon": true, - "METAL_VERSION": true - } -} diff --git a/packages/metal-incremental-dom/test/IncrementalDomRenderer.js b/packages/metal-incremental-dom/test/IncrementalDomRenderer.js index a083a028..5687f07d 100644 --- a/packages/metal-incremental-dom/test/IncrementalDomRenderer.js +++ b/packages/metal-incremental-dom/test/IncrementalDomRenderer.js @@ -1,17 +1,17 @@ 'use strict'; -import { async, core, object } from 'metal'; +import {async, core, object} from 'metal'; import dom from 'metal-dom'; -import { getData } from '../src/data'; -import { sunset } from '../../../test-utils'; -import { CHILD_OWNER } from '../src/children/children'; -import { Component, ComponentRegistry } from 'metal-component'; +import {getData} from '../src/data'; +import {sunset} from '../../../test-utils'; +import {CHILD_OWNER} from '../src/children/children'; +import {Component, ComponentRegistry} from 'metal-component'; import IncrementalDomRenderer from '../src/IncrementalDomRenderer'; -var IncDom = IncrementalDOM; +let IncDom = IncrementalDOM; describe('IncrementalDomRenderer', function() { - var component; + let component; afterEach(function() { if (component) { @@ -21,8 +21,7 @@ describe('IncrementalDomRenderer', function() { describe('Default render', function() { it('should render empty div element by default', function() { - class TestComponent extends Component { - } + class TestComponent extends Component {} TestComponent.RENDERER = IncrementalDomRenderer; component = new TestComponent(); @@ -41,8 +40,7 @@ describe('IncrementalDomRenderer', function() { } } - class TestComponent extends Component { - } + class TestComponent extends Component {} TestComponent.RENDERER = new TestRenderer(); component = new TestComponent(); @@ -77,7 +75,7 @@ describe('IncrementalDomRenderer', function() { } } TestComponent.STATE = { - attr: {} + attr: {}, }; TestComponent.RENDERER = IncrementalDomRenderer; @@ -95,9 +93,9 @@ describe('IncrementalDomRenderer', function() { } TestComponent.RENDERER = IncrementalDomRenderer; - var element = document.createElement('span'); + let element = document.createElement('span'); component = new TestComponent({ - element: element + element: element, }); assert.strictEqual(element, component.element); assert.strictEqual('foo', component.element.getAttribute('foo')); @@ -105,7 +103,7 @@ describe('IncrementalDomRenderer', function() { }); it('should run component\'s "rendered" lifecycle method on first render', function() { - var calledArgs = []; + let calledArgs = []; class TestComponent extends Component { render() { IncDom.elementOpen('span', null, null, 'foo', 'foo'); @@ -135,8 +133,8 @@ describe('IncrementalDomRenderer', function() { TestComponent.RENDERER = IncrementalDomRenderer; TestComponent.STATE = { foo: { - value: 'foo' - } + value: 'foo', + }, }; component = new TestComponent(); @@ -160,8 +158,8 @@ describe('IncrementalDomRenderer', function() { TestComponent.RENDERER = IncrementalDomRenderer; TestComponent.STATE = { foo: { - value: 'foo' - } + value: 'foo', + }, }; TestComponent.SYNC_UPDATES = true; @@ -188,8 +186,7 @@ describe('IncrementalDomRenderer', function() { } TestComponent.RENDERER = IncrementalDomRenderer; TestComponent.STATE = { - foo: { - } + foo: {}, }; TestComponent.SYNC_UPDATES = true; @@ -241,8 +238,10 @@ describe('IncrementalDomRenderer', function() { assert.equal(component.shouldUpdate.callCount, 0); }); - it('should run component\'s "rendered" lifecycle method on updates', function(done) { - var calledArgs = []; + it('should run component\'s "rendered" lifecycle method on updates', function( + done + ) { + let calledArgs = []; class TestComponent extends Component { render() { IncDom.elementOpen('div'); @@ -257,8 +256,8 @@ describe('IncrementalDomRenderer', function() { TestComponent.RENDERER = IncrementalDomRenderer; TestComponent.STATE = { foo: { - value: 'foo' - } + value: 'foo', + }, }; component = new TestComponent(); @@ -281,9 +280,9 @@ describe('IncrementalDomRenderer', function() { } TestComponent.RENDERER = IncrementalDomRenderer; - var element = document.createElement('div'); + let element = document.createElement('div'); component = new TestComponent({ - element: element + element: element, }); assert.notStrictEqual(element, component.element); assert.strictEqual('SPAN', component.element.tagName); @@ -297,11 +296,11 @@ describe('IncrementalDomRenderer', function() { } TestComponent.RENDERER = IncrementalDomRenderer; - var element = document.createElement('div'); - var parent = document.createElement('div'); + let element = document.createElement('div'); + let parent = document.createElement('div'); component = new TestComponent( { - element: element + element: element, }, parent ); @@ -319,7 +318,9 @@ describe('IncrementalDomRenderer', function() { assert.ok(!component.element); }); - it('should reposition component on requested parent when its content is back after an update', function(done) { + it('should reposition component on requested parent when its content is back after an update', function( + done + ) { class TestComponent extends Component { render() { if (!this.noElement) { @@ -329,16 +330,15 @@ describe('IncrementalDomRenderer', function() { } TestComponent.RENDERER = IncrementalDomRenderer; TestComponent.STATE = { - noElement: { - } + noElement: {}, }; - var parent = document.createElement('div'); + let parent = document.createElement('div'); component = new TestComponent({}, parent); assert.ok(component.element); assert.strictEqual(parent, component.element.parentNode); - var prevElement = component.element; + let prevElement = component.element; component.noElement = true; component.once('stateSynced', function() { assert.ok(!component.element); @@ -362,7 +362,7 @@ describe('IncrementalDomRenderer', function() { TestComponent.RENDERER = IncrementalDomRenderer; component = new TestComponent({ - elementClasses: 'test' + elementClasses: 'test', }); assert.ok(dom.hasClass(component.element, 'test')); @@ -374,22 +374,32 @@ describe('IncrementalDomRenderer', function() { }); }); - it('should add/remove css classes by using both "class" and "elementClasses"', function(done) { + it('should add/remove css classes by using both "class" and "elementClasses"', function( + done + ) { class TestComponent extends Component { render() { - var cssClass = this.foo ? 'foo' : 'bar'; - IncDom.elementVoid('button', null, [], 'foo', 'foo', 'class', cssClass); + let cssClass = this.foo ? 'foo' : 'bar'; + IncDom.elementVoid( + 'button', + null, + [], + 'foo', + 'foo', + 'class', + cssClass + ); } } TestComponent.RENDERER = IncrementalDomRenderer; TestComponent.STATE = { foo: { - value: true - } + value: true, + }, }; component = new TestComponent({ - elementClasses: 'test' + elementClasses: 'test', }); assert.ok(dom.hasClass(component.element, 'foo')); assert.ok(!dom.hasClass(component.element, 'bar')); @@ -413,9 +423,12 @@ describe('IncrementalDomRenderer', function() { TestComponent.RENDERER = IncrementalDomRenderer; component = new TestComponent({ - elementClasses: 'test2 test3' + elementClasses: 'test2 test3', }); - assert.strictEqual('test1 test2 test3', component.element.getAttribute('class')); + assert.strictEqual( + 'test1 test2 test3', + component.element.getAttribute('class') + ); }); it('should store references to node elements via "ref"', function() { @@ -431,8 +444,14 @@ describe('IncrementalDomRenderer', function() { component = new TestComponent(); assert.strictEqual(component.element, component.refs.root); - assert.strictEqual(component.element.childNodes[0], component.refs.child1); - assert.strictEqual(component.element.childNodes[1], component.refs.child2); + assert.strictEqual( + component.element.childNodes[0], + component.refs.child1 + ); + assert.strictEqual( + component.element.childNodes[1], + component.refs.child2 + ); }); }); @@ -449,15 +468,18 @@ describe('IncrementalDomRenderer', function() { } TestComponent.RENDERER = IncrementalDomRenderer; - var element = document.createElement('div'); + let element = document.createElement('div'); dom.append(element, '
foo
'); - var innerElement = element.querySelector('.inner'); + let innerElement = element.querySelector('.inner'); component = new TestComponent({ - element: element + element: element, }); assert.strictEqual(element, component.element); - assert.strictEqual(innerElement, component.element.querySelector('.inner')); + assert.strictEqual( + innerElement, + component.element.querySelector('.inner') + ); assert.strictEqual('foo', component.element.textContent); }); @@ -473,15 +495,18 @@ describe('IncrementalDomRenderer', function() { } TestComponent.RENDERER = IncrementalDomRenderer; - var element = document.createElement('div'); + let element = document.createElement('div'); dom.append(element, 'foo'); - var innerElement = element.querySelector('.inner'); + let innerElement = element.querySelector('.inner'); component = new TestComponent({ - element: element + element: element, }); assert.strictEqual(element, component.element); - assert.notStrictEqual(innerElement, component.element.querySelector('.inner')); + assert.notStrictEqual( + innerElement, + component.element.querySelector('.inner') + ); assert.strictEqual('foo', component.element.textContent); }); @@ -497,15 +522,18 @@ describe('IncrementalDomRenderer', function() { } TestComponent.RENDERER = IncrementalDomRenderer; - var element = document.createElement('div'); + let element = document.createElement('div'); dom.append(element, '
foo
'); - var innerElement = element.querySelector('.inner2'); + let innerElement = element.querySelector('.inner2'); component = new TestComponent({ - element: element + element: element, }); assert.strictEqual(element, component.element); - assert.strictEqual(innerElement, component.element.querySelector('.inner')); + assert.strictEqual( + innerElement, + component.element.querySelector('.inner') + ); assert.strictEqual('foo', component.element.textContent); assert.ok(dom.hasClass(innerElement, 'inner')); assert.ok(!dom.hasClass(innerElement, 'inner2')); @@ -580,12 +608,12 @@ describe('IncrementalDomRenderer', function() { TestComponent.RENDERER = IncrementalDomRenderer; TestComponent.prototype.handleClick = sinon.stub(); - var element = document.createElement('div'); + let element = document.createElement('div'); element.setAttribute('data-onclick', 'handleClick'); dom.enterDocument(element); component = new TestComponent({ - element: element + element: element, }); dom.triggerEvent(component.element, 'click'); @@ -628,11 +656,11 @@ describe('IncrementalDomRenderer', function() { TestComponent.RENDERER = IncrementalDomRenderer; TestComponent.prototype.handleClick = sinon.stub(); - var element = document.createElement('div'); + let element = document.createElement('div'); dom.append(element, '
'); - var innerElement = element.childNodes[0]; + let innerElement = element.childNodes[0]; component = new TestComponent({ - element: element + element: element, }); assert.strictEqual(innerElement, component.element.childNodes[0]); @@ -643,7 +671,13 @@ describe('IncrementalDomRenderer', function() { it('should provide delegateTarget as the element that the listener was attached to', function() { class TestComponent extends Component { render() { - IncDom.elementOpen('div', null, null, 'onClick', 'handleElementClick'); + IncDom.elementOpen( + 'div', + null, + null, + 'onClick', + 'handleElementClick' + ); IncDom.elementOpen('div', null, null, 'onClick', 'handleClick'); IncDom.elementVoid('div', null, null, 'class', 'inner'); IncDom.elementClose('div'); @@ -652,17 +686,17 @@ describe('IncrementalDomRenderer', function() { } TestComponent.RENDERER = IncrementalDomRenderer; - var event1; + let event1; TestComponent.prototype.handleElementClick = function(event) { event1 = object.mixin({}, event); }; - var event2; + let event2; TestComponent.prototype.handleClick = function(event) { event2 = object.mixin({}, event); }; component = new TestComponent(); - var innerElement = component.element.querySelector('.inner'); + let innerElement = component.element.querySelector('.inner'); dom.triggerEvent(innerElement, 'click'); assert.ok(event1); @@ -671,10 +705,15 @@ describe('IncrementalDomRenderer', function() { assert.ok(event2); assert.strictEqual(innerElement, event2.target); - assert.strictEqual(component.element.childNodes[0], event2.delegateTarget); + assert.strictEqual( + component.element.childNodes[0], + event2.delegateTarget + ); }); - it('should remove unused inline listeners when dom is updated', function(done) { + it('should remove unused inline listeners when dom is updated', function( + done + ) { class TestComponent extends Component { render() { IncDom.elementOpen('div'); @@ -690,8 +729,8 @@ describe('IncrementalDomRenderer', function() { TestComponent.RENDERER = IncrementalDomRenderer; TestComponent.STATE = { keydown: { - value: true - } + value: true, + }, }; TestComponent.prototype.handleClick = sinon.stub(); TestComponent.prototype.handleKeydown = sinon.stub(); @@ -712,14 +751,14 @@ describe('IncrementalDomRenderer', function() { class TestComponent extends Component { render() { IncDom.elementOpen('div'); - var fn = this.switch ? this.handleClick2 : this.handleClick; + let fn = this.switch ? this.handleClick2 : this.handleClick; IncDom.elementVoid('div', null, null, 'onClick', fn); IncDom.elementClose('div'); } } TestComponent.RENDERER = IncrementalDomRenderer; TestComponent.STATE = { - switch: {} + switch: {}, }; TestComponent.prototype.handleClick = sinon.stub(); TestComponent.prototype.handleClick2 = sinon.stub(); @@ -744,8 +783,7 @@ describe('IncrementalDomRenderer', function() { sinon.stub(this, 'handleClick'); } - handleClick() { - } + handleClick() {} render() { IncDom.elementVoid('div', null, null, 'data-onclick', 'handleClick'); @@ -759,7 +797,7 @@ describe('IncrementalDomRenderer', function() { component.dispose(); component = new TestComponent({ - element + element, }); dom.triggerEvent(element, 'click'); assert.equal(1, component.handleClick.callCount); @@ -767,7 +805,7 @@ describe('IncrementalDomRenderer', function() { }); describe('Nested Components', function() { - var ChildComponent; + let ChildComponent; beforeEach(function() { class ChildComponentClass extends Component { @@ -782,8 +820,8 @@ describe('IncrementalDomRenderer', function() { ChildComponent.RENDERER = IncrementalDomRenderer; ChildComponent.STATE = { foo: { - value: 'foo' - } + value: 'foo', + }, }; ChildComponent.prototype.handleClick = sinon.stub(); ComponentRegistry.register(ChildComponent, 'ChildComponent'); @@ -800,7 +838,7 @@ describe('IncrementalDomRenderer', function() { TestComponent.RENDERER = IncrementalDomRenderer; component = new TestComponent(); - var child = component.components.child; + let child = component.components.child; assert.ok(child); assert.ok(child instanceof ChildComponent); assert.strictEqual(child, component.refs.child); @@ -817,8 +855,11 @@ describe('IncrementalDomRenderer', function() { TestComponent.RENDERER = IncrementalDomRenderer; component = new TestComponent(); - var child = component.components.child; - assert.strictEqual(child.element, component.element.querySelector('child')); + let child = component.components.child; + assert.strictEqual( + child.element, + component.element.querySelector('child') + ); assert.strictEqual('foo', child.element.textContent); assert.ok(child.element.hasAttribute('data-child')); }); @@ -837,7 +878,7 @@ describe('IncrementalDomRenderer', function() { sinon.spy(ChildComponent.prototype, 'attached'); component = new TestComponent(); - var child = component.components.child; + let child = component.components.child; assert.strictEqual(1, child.rendered.callCount); assert.ok(child.rendered.args[0][0]); assert.strictEqual(1, child.attached.callCount); @@ -847,14 +888,22 @@ describe('IncrementalDomRenderer', function() { class TestComponent extends Component { render() { IncDom.elementOpen('div'); - IncDom.elementVoid('ChildComponent', null, null, 'ref', 'child', 'foo', 'bar'); + IncDom.elementVoid( + 'ChildComponent', + null, + null, + 'ref', + 'child', + 'foo', + 'bar' + ); IncDom.elementClose('div'); } } TestComponent.RENDERER = IncrementalDomRenderer; component = new TestComponent(); - var child = component.components.child; + let child = component.components.child; assert.strictEqual('bar', child.foo); assert.strictEqual('bar', child.element.textContent); }); @@ -863,40 +912,58 @@ describe('IncrementalDomRenderer', function() { class TestComponent extends Component { render() { IncDom.elementOpen('div'); - IncDom.elementVoid('ChildComponent', null, null, 'ref', 'child', 'foo', this.foo); + IncDom.elementVoid( + 'ChildComponent', + null, + null, + 'ref', + 'child', + 'foo', + this.foo + ); IncDom.elementClose('div'); } } TestComponent.RENDERER = IncrementalDomRenderer; TestComponent.STATE = { foo: { - value: 'foo' - } + value: 'foo', + }, }; component = new TestComponent(); component.foo = 'bar'; component.once('stateSynced', function() { - var child = component.components.child; + let child = component.components.child; assert.strictEqual('bar', child.foo); assert.strictEqual('bar', child.element.textContent); done(); }); }); - it('should run component\'s lifecycle methods when updated as sub component', function(done) { + it('should run component\'s lifecycle methods when updated as sub component', function( + done + ) { class TestComponent extends Component { render() { IncDom.elementOpen('div'); - IncDom.elementVoid('ChildComponent', null, null, 'ref', 'child', 'foo', this.foo); + IncDom.elementVoid( + 'ChildComponent', + null, + null, + 'ref', + 'child', + 'foo', + this.foo + ); IncDom.elementClose('div'); } } TestComponent.RENDERER = IncrementalDomRenderer; TestComponent.STATE = { foo: { - value: 'foo' - } + value: 'foo', + }, }; sinon.spy(ChildComponent.prototype, 'rendered'); @@ -905,7 +972,7 @@ describe('IncrementalDomRenderer', function() { component.foo = 'bar'; component.once('stateSynced', function() { - var child = component.components.child; + let child = component.components.child; assert.strictEqual(2, child.rendered.callCount); assert.ok(!child.rendered.args[1][0]); assert.strictEqual(1, child.attached.callCount); @@ -913,25 +980,35 @@ describe('IncrementalDomRenderer', function() { }); }); - it('should not try to rerender sub component later when state changes during parent rendering', function(done) { + it('should not try to rerender sub component later when state changes during parent rendering', function( + done + ) { class TestComponent extends Component { render() { IncDom.elementOpen('div'); - IncDom.elementVoid('ChildComponent', null, null, 'ref', 'child', 'foo', this.foo); + IncDom.elementVoid( + 'ChildComponent', + null, + null, + 'ref', + 'child', + 'foo', + this.foo + ); IncDom.elementClose('div'); } } TestComponent.RENDERER = IncrementalDomRenderer; TestComponent.STATE = { foo: { - value: 'foo' - } + value: 'foo', + }, }; component = new TestComponent(); component.foo = 'bar'; component.once('stateSynced', function() { - var child = component.components.child; + let child = component.components.child; sinon.spy(child, 'render'); child.once('stateSynced', function() { assert.strictEqual(0, child.render.callCount); @@ -940,25 +1017,35 @@ describe('IncrementalDomRenderer', function() { }); }); - it('should rerender sub component when state changes after parent rendering', function(done) { + it('should rerender sub component when state changes after parent rendering', function( + done + ) { class TestComponent extends Component { render() { IncDom.elementOpen('div'); - IncDom.elementVoid('ChildComponent', null, null, 'ref', 'child', 'foo', this.foo); + IncDom.elementVoid( + 'ChildComponent', + null, + null, + 'ref', + 'child', + 'foo', + this.foo + ); IncDom.elementClose('div'); } } TestComponent.RENDERER = IncrementalDomRenderer; TestComponent.STATE = { foo: { - value: 'foo' - } + value: 'foo', + }, }; component = new TestComponent(); component.foo = 'bar'; component.once('stateSynced', function() { - var child = component.components.child; + let child = component.components.child; child.foo = 'bar2'; sinon.spy(child, 'render'); child.once('stateSynced', function() { @@ -969,7 +1056,9 @@ describe('IncrementalDomRenderer', function() { }); }); - it('should not remove sub component key when this sub component updates itself', function(done) { + it('should not remove sub component key when this sub component updates itself', function( + done + ) { class TestComponent extends Component { render() { IncDom.elementOpen('div'); @@ -980,13 +1069,16 @@ describe('IncrementalDomRenderer', function() { TestComponent.RENDERER = IncrementalDomRenderer; component = new TestComponent(); - var child = component.components.child; + let child = component.components.child; assert.strictEqual('childKey', child.element.__incrementalDOMData.key); child.foo = 'bar'; child.once('stateSynced', function() { assert.strictEqual('childKey', child.element.__incrementalDOMData.key); - assert.strictEqual(child.element, component.element.querySelector('child')); + assert.strictEqual( + child.element, + component.element.querySelector('child') + ); assert.strictEqual('bar', child.element.textContent); done(); }); @@ -1026,16 +1118,18 @@ describe('IncrementalDomRenderer', function() { TestComponent.RENDERER = IncrementalDomRenderer; component = new TestComponent(); - var child = component.components.child; + let child = component.components.child; assert.strictEqual(0, child.handleClick.callCount); - var button = child.element.querySelector('button'); + let button = child.element.querySelector('button'); dom.triggerEvent(button, 'click'); assert.strictEqual(1, child.handleClick.callCount); }); - it('should detach unused sub component inline listeners after parent update', function(done) { + it('should detach unused sub component inline listeners after parent update', function( + done + ) { class TestChildComponent extends Component { render() { if (this.removeEvent) { @@ -1049,24 +1143,30 @@ describe('IncrementalDomRenderer', function() { TestChildComponent.prototype.handleClick = sinon.stub(); TestChildComponent.RENDERER = IncrementalDomRenderer; TestChildComponent.STATE = { - removeEvent: { - } + removeEvent: {}, }; class TestComponent extends Component { render() { IncDom.elementOpen('div'); - IncDom.elementVoid(TestChildComponent, null, null, 'ref', 'child', 'removeEvent', this.removeEvent); + IncDom.elementVoid( + TestChildComponent, + null, + null, + 'ref', + 'child', + 'removeEvent', + this.removeEvent + ); IncDom.elementClose('div'); } } TestComponent.RENDERER = IncrementalDomRenderer; TestComponent.STATE = { - removeEvent: { - } + removeEvent: {}, }; component = new TestComponent(); - var child = component.components.child; + let child = component.components.child; dom.triggerEvent(child.element, 'click'); assert.strictEqual(1, child.handleClick.callCount); @@ -1096,8 +1196,10 @@ describe('IncrementalDomRenderer', function() { assert.strictEqual('bar', component.element.childNodes[0].textContent); }); - it('should reuse sub component even when it receives no ref', function(done) { - var creationCount = 0; + it('should reuse sub component even when it receives no ref', function( + done + ) { + let creationCount = 0; class TestChildComponent extends Component { created() { creationCount++; @@ -1111,8 +1213,7 @@ describe('IncrementalDomRenderer', function() { } TestChildComponent.RENDERER = IncrementalDomRenderer; TestChildComponent.STATE = { - foo: { - } + foo: {}, }; class TestComponent extends Component { @@ -1125,8 +1226,8 @@ describe('IncrementalDomRenderer', function() { TestComponent.RENDERER = IncrementalDomRenderer; TestComponent.STATE = { foo: { - value: 'foo' - } + value: 'foo', + }, }; component = new TestComponent(); @@ -1164,11 +1265,10 @@ describe('IncrementalDomRenderer', function() { } TestComponent.RENDERER = IncrementalDomRenderer; TestComponent.STATE = { - add: { - } + add: {}, }; - var children = []; + let children = []; sinon.stub(ChildComponent.prototype, 'created', function() { children.push(this); }); @@ -1192,13 +1292,21 @@ describe('IncrementalDomRenderer', function() { assert.strictEqual('foo', component.element.childNodes[1].textContent); assert.strictEqual('CHILD', component.element.childNodes[2].tagName); assert.strictEqual('bar', component.element.childNodes[2].textContent); - assert.strictEqual(component.element.childNodes[1], children[0].element); - assert.strictEqual(component.element.childNodes[2], children[1].element); + assert.strictEqual( + component.element.childNodes[1], + children[0].element + ); + assert.strictEqual( + component.element.childNodes[2], + children[1].element + ); done(); }); }); - it('should reuse correct children according to their "key" after an update', function(done) { + it('should reuse correct children according to their "key" after an update', function( + done + ) { class TestComponent extends Component { render() { IncDom.elementOpen('div'); @@ -1214,11 +1322,10 @@ describe('IncrementalDomRenderer', function() { } TestComponent.RENDERER = IncrementalDomRenderer; TestComponent.STATE = { - switch: { - } + switch: {}, }; - var children = []; + let children = []; sinon.stub(ChildComponent.prototype, 'created', function() { children.push(this); }); @@ -1233,13 +1340,21 @@ describe('IncrementalDomRenderer', function() { component.once('stateSynced', function() { assert.strictEqual(2, component.element.childNodes.length); assert.strictEqual(2, children.length); - assert.strictEqual(component.element.childNodes[0], children[1].element); - assert.strictEqual(component.element.childNodes[1], children[0].element); + assert.strictEqual( + component.element.childNodes[0], + children[1].element + ); + assert.strictEqual( + component.element.childNodes[1], + children[0].element + ); done(); }); }); - it('should not reuse component that was created in another parent', function(done) { + it('should not reuse component that was created in another parent', function( + done + ) { const grandChildInstances = []; class GrandChildComponent extends Component { created() { @@ -1262,14 +1377,20 @@ describe('IncrementalDomRenderer', function() { class TestComponent extends Component { render() { - IncDom.elementVoid(TestChildComponent, null, null, 'ref', 'child' + this.number); + IncDom.elementVoid( + TestChildComponent, + null, + null, + 'ref', + 'child' + this.number + ); } } TestComponent.RENDERER = IncrementalDomRenderer; TestComponent.STATE = { number: { - value: 1 - } + value: 1, + }, }; component = new TestComponent(); @@ -1280,12 +1401,17 @@ describe('IncrementalDomRenderer', function() { assert.strictEqual(2, grandChildInstances.length); assert.ok(grandChildInstances[0].isDisposed()); assert.ok(!grandChildInstances[1].isDisposed()); - assert.strictEqual(grandChildInstances[1].element, component.element.querySelector('span')); + assert.strictEqual( + grandChildInstances[1].element, + component.element.querySelector('span') + ); done(); }); }); - it('should not throw error trying to reuse component that was disposed', function(done) { + it('should not throw error trying to reuse component that was disposed', function( + done + ) { const childInstances = []; class TestChildComponent extends Component { created() { @@ -1304,8 +1430,7 @@ describe('IncrementalDomRenderer', function() { } TestComponent.RENDERER = IncrementalDomRenderer; TestComponent.STATE = { - foo: { - } + foo: {}, }; component = new TestComponent(); @@ -1322,11 +1447,13 @@ describe('IncrementalDomRenderer', function() { }); }); - it('should reuse previous internal state data on sub component rerender', function(done) { + it('should reuse previous internal state data on sub component rerender', function( + done + ) { ChildComponent.STATE = { foo: { - internal: true - } + internal: true, + }, }; class TestComponent extends Component { @@ -1335,19 +1462,26 @@ describe('IncrementalDomRenderer', function() { if (this.noFoo) { IncDom.elementVoid(ChildComponent, null, null, 'ref', 'child'); } else { - IncDom.elementVoid(ChildComponent, null, null, 'ref', 'child', 'foo', 'foo'); + IncDom.elementVoid( + ChildComponent, + null, + null, + 'ref', + 'child', + 'foo', + 'foo' + ); } IncDom.elementClose('div'); } } TestComponent.RENDERER = IncrementalDomRenderer; TestComponent.STATE = { - noFoo: { - } + noFoo: {}, }; component = new TestComponent(); - var child = component.components.child; + let child = component.components.child; assert.strictEqual('foo', child.foo); component.noFoo = true; @@ -1357,11 +1491,13 @@ describe('IncrementalDomRenderer', function() { }); }); - it('should not reuse previous non internal state data on sub component rerender', function(done) { + it('should not reuse previous non internal state data on sub component rerender', function( + done + ) { ChildComponent.STATE = { foo: { - value: 'defaultFoo' - } + value: 'defaultFoo', + }, }; class TestComponent extends Component { @@ -1370,19 +1506,26 @@ describe('IncrementalDomRenderer', function() { if (this.noFoo) { IncDom.elementVoid(ChildComponent, null, null, 'ref', 'child'); } else { - IncDom.elementVoid(ChildComponent, null, null, 'ref', 'child', 'foo', 'foo'); + IncDom.elementVoid( + ChildComponent, + null, + null, + 'ref', + 'child', + 'foo', + 'foo' + ); } IncDom.elementClose('div'); } } TestComponent.RENDERER = IncrementalDomRenderer; TestComponent.STATE = { - noFoo: { - } + noFoo: {}, }; component = new TestComponent(); - var child = component.components.child; + let child = component.components.child; assert.strictEqual('foo', child.foo); component.noFoo = true; @@ -1423,8 +1566,11 @@ describe('IncrementalDomRenderer', function() { TestComponent.RENDERER = IncrementalDomRenderer; component = new TestComponent(); - var child = component.components.child; - assert.strictEqual(child.element, component.element.querySelector('child')); + let child = component.components.child; + assert.strictEqual( + child.element, + component.element.querySelector('child') + ); assert.strictEqual('foo', child.element.textContent); assert.ok(child.element.hasAttribute('data-child')); }); @@ -1444,9 +1590,12 @@ describe('IncrementalDomRenderer', function() { TestComponent.RENDERER = IncrementalDomRenderer; component = new TestComponent(); - var child = component.components.child; + let child = component.components.child; assert.strictEqual('bar', child.foo); - assert.strictEqual(child.element, component.element.querySelector('child')); + assert.strictEqual( + child.element, + component.element.querySelector('child') + ); assert.strictEqual('bar', child.element.textContent); assert.ok(child.element.hasAttribute('data-child')); }); @@ -1462,9 +1611,12 @@ describe('IncrementalDomRenderer', function() { TestComponent.RENDERER = IncrementalDomRenderer; component = new TestComponent(); - var child = component.components.child; + let child = component.components.child; assert.ok(child instanceof ChildComponent); - assert.strictEqual(child.element, component.element.querySelector('child')); + assert.strictEqual( + child.element, + component.element.querySelector('child') + ); assert.strictEqual('foo', child.element.textContent); assert.ok(child.element.hasAttribute('data-child')); }); @@ -1473,31 +1625,41 @@ describe('IncrementalDomRenderer', function() { class TestComponent extends Component { render() { IncDom.elementOpen('div'); - IncDom.elementVoid(ChildComponent, null, [], 'ref', 'child', 'foo', this.foo); + IncDom.elementVoid( + ChildComponent, + null, + [], + 'ref', + 'child', + 'foo', + this.foo + ); IncDom.elementClose('div'); } } TestComponent.RENDERER = IncrementalDomRenderer; TestComponent.STATE = { - foo: {} + foo: {}, }; component = new TestComponent({ - foo: 'foo' + foo: 'foo', }); - var child = component.components.child; + let child = component.components.child; assert.strictEqual('foo', child.foo); component.foo = 'bar'; component.once('stateSynced', function() { - var newChild = component.components.child; + let newChild = component.components.child; assert.strictEqual(child, newChild); assert.strictEqual('bar', child.foo); done(); }); }); - it('should not reuse component with same key if constructor is different"', function(done) { + it('should not reuse component with same key if constructor is different"', function( + done + ) { class TestChildComponent extends Component { render() { IncDom.elementVoid('div'); @@ -1518,19 +1680,18 @@ describe('IncrementalDomRenderer', function() { } TestComponent.RENDERER = IncrementalDomRenderer; TestComponent.STATE = { - switch: { - } + switch: {}, }; component = new TestComponent(); - var child = component.components.child; + let child = component.components.child; assert.ok(child instanceof ChildComponent); assert.strictEqual(child.element, component.element.childNodes[0]); assert.strictEqual('CHILD', child.element.tagName); component.switch = true; component.once('stateSynced', function() { - var newChild = component.components.child; + let newChild = component.components.child; assert.notStrictEqual(child, newChild); assert.ok(newChild instanceof TestChildComponent); assert.strictEqual(newChild.element, component.element.childNodes[0]); @@ -1541,7 +1702,9 @@ describe('IncrementalDomRenderer', function() { }); }); - it('should call "detached" lifecycle function and event when sub component is removed', function(done) { + it('should call "detached" lifecycle function and event when sub component is removed', function( + done + ) { class TestComponent extends Component { render() { IncDom.elementOpen('div'); @@ -1553,12 +1716,11 @@ describe('IncrementalDomRenderer', function() { } TestComponent.RENDERER = IncrementalDomRenderer; TestComponent.STATE = { - remove: { - } + remove: {}, }; component = new TestComponent(); - var child = component.components.child; + let child = component.components.child; assert.ok(!child.isDisposed()); sinon.spy(child, 'detached'); @@ -1611,11 +1773,13 @@ describe('IncrementalDomRenderer', function() { TestComponent.RENDERER = IncrementalDomRenderer; component = new TestComponent(); - var child = component.components.child; + let child = component.components.child; assert.strictEqual(child.element, component.element); }); - it('should position previously empty child component correctly inside parent', function(done) { + it('should position previously empty child component correctly inside parent', function( + done + ) { class TestChildComponent extends Component { render() { if (!this.empty) { @@ -1627,8 +1791,8 @@ describe('IncrementalDomRenderer', function() { TestChildComponent.STATE = { empty: { value: true, - internal: true - } + internal: true, + }, }; class TestComponent extends Component { @@ -1641,7 +1805,7 @@ describe('IncrementalDomRenderer', function() { TestComponent.RENDERER = IncrementalDomRenderer; component = new TestComponent(); - var child = component.components.child; + let child = component.components.child; assert.ok(!child.element); assert.strictEqual(0, component.element.childNodes.length); @@ -1654,25 +1818,35 @@ describe('IncrementalDomRenderer', function() { }); }); - it('should not render sub component with SYNC_UPDATES twice', function(done) { + it('should not render sub component with SYNC_UPDATES twice', function( + done + ) { ChildComponent.SYNC_UPDATES = true; class TestComponent extends Component { render() { IncDom.elementOpen('div'); - IncDom.elementVoid(ChildComponent, null, null, 'ref', 'child', 'foo', this.foo); + IncDom.elementVoid( + ChildComponent, + null, + null, + 'ref', + 'child', + 'foo', + this.foo + ); IncDom.elementClose('div'); } } TestComponent.RENDERER = IncrementalDomRenderer; TestComponent.STATE = { foo: { - value: 'foo' - } + value: 'foo', + }, }; component = new TestComponent(); - var child = component.components.child; + let child = component.components.child; sinon.spy(child, 'render'); component.foo = 'bar'; @@ -1684,8 +1858,7 @@ describe('IncrementalDomRenderer', function() { describe('Children data', function() { it('should pass tree of incremental dom calls as "children"', function() { - class TestChildComponent extends Component { - } + class TestChildComponent extends Component {} TestChildComponent.RENDERER = IncrementalDomRenderer; class TestComponent extends Component { @@ -1702,10 +1875,10 @@ describe('IncrementalDomRenderer', function() { TestComponent.RENDERER = IncrementalDomRenderer; component = new TestComponent(); - var child = component.components.child; + let child = component.components.child; assert.ok(child instanceof TestChildComponent); - var children = child.children; + let children = child.children; assert.ok(children); assert.strictEqual(1, children.length); @@ -1741,11 +1914,14 @@ describe('IncrementalDomRenderer', function() { TestComponent.RENDERER = IncrementalDomRenderer; component = new TestComponent(); - var child = component.components.child; + let child = component.components.child; assert.ok(child instanceof TestChildComponent); assert.strictEqual(1, child.element.childNodes.length); assert.strictEqual('SPAN', child.element.childNodes[0].tagName); - assert.strictEqual('Hello World', child.element.childNodes[0].textContent); + assert.strictEqual( + 'Hello World', + child.element.childNodes[0].textContent + ); }); it('should render empty string children', function() { @@ -1770,7 +1946,7 @@ describe('IncrementalDomRenderer', function() { TestComponent.RENDERER = IncrementalDomRenderer; component = new TestComponent(); - var child = component.components.child; + let child = component.components.child; assert.strictEqual('foo bar', child.element.textContent); }); @@ -1798,7 +1974,7 @@ describe('IncrementalDomRenderer', function() { TestComponent.RENDERER = IncrementalDomRenderer; component = new TestComponent(); - var child = component.components.child; + let child = component.components.child; assert.strictEqual(1, child.element.childNodes.length); assert.strictEqual('SPAN', child.element.childNodes[0].tagName); assert.ok(dom.hasClass(child.element.childNodes[0], 'second')); @@ -1816,7 +1992,13 @@ describe('IncrementalDomRenderer', function() { class TestNestedChildComponent extends Component { render() { - IncDom.elementOpen(TestChildComponent, null, null, 'ref', 'nestedChild1'); + IncDom.elementOpen( + TestChildComponent, + null, + null, + 'ref', + 'nestedChild1' + ); IncDom.elementOpen('div'); this.children.forEach(IncrementalDomRenderer.renderChild); IncDom.elementClose('div'); @@ -1828,7 +2010,13 @@ describe('IncrementalDomRenderer', function() { class TestComponent extends Component { render() { IncDom.elementOpen('div'); - IncDom.elementOpen(TestNestedChildComponent, null, null, 'ref', 'child1'); + IncDom.elementOpen( + TestNestedChildComponent, + null, + null, + 'ref', + 'child1' + ); IncDom.elementVoid(TestChildComponent, null, null, 'ref', 'child2'); IncDom.elementClose(TestNestedChildComponent); IncDom.elementClose('div'); @@ -1837,8 +2025,8 @@ describe('IncrementalDomRenderer', function() { TestComponent.RENDERER = IncrementalDomRenderer; component = new TestComponent(); - var child1 = component.components.child1; - var child2 = component.components.child2; + let child1 = component.components.child1; + let child2 = component.components.child2; assert.ok(child1 instanceof TestNestedChildComponent); assert.ok(child2 instanceof TestChildComponent); assert.ok(child1.components.nestedChild1 instanceof TestChildComponent); @@ -1846,7 +2034,10 @@ describe('IncrementalDomRenderer', function() { assert.ok(!child1.components.child2); assert.strictEqual(child1.element, component.element.childNodes[0]); - assert.strictEqual(child2.element, child1.element.childNodes[0].childNodes[0]); + assert.strictEqual( + child2.element, + child1.element.childNodes[0].childNodes[0] + ); }); it('should add dom element references to the component that requested them', function() { @@ -1882,7 +2073,7 @@ describe('IncrementalDomRenderer', function() { TestComponent.RENDERER = IncrementalDomRenderer; component = new TestComponent(); - var childEl = component.refs.childEl; + let childEl = component.refs.childEl; assert.ok(childEl); assert.ok(core.isElement(childEl)); assert.strictEqual('SPAN', childEl.tagName); @@ -1928,9 +2119,13 @@ describe('IncrementalDomRenderer', function() { render() { IncrementalDOM.elementOpen('child'); if (this.children.length) { - this.children[0].props = object.mixin({}, this.children[0].props, { - foo: 'changedFoo' - }); + this.children[0].props = object.mixin( + {}, + this.children[0].props, + { + foo: 'changedFoo', + } + ); this.children.forEach(IncrementalDomRenderer.renderChild); } if (this.foo) { @@ -1941,8 +2136,7 @@ describe('IncrementalDomRenderer', function() { } TestChildComponent.RENDERER = IncrementalDomRenderer; TestChildComponent.STATE = { - foo: { - } + foo: {}, }; class TestNestedChildComponent extends Component { @@ -1965,7 +2159,10 @@ describe('IncrementalDomRenderer', function() { component = new TestComponent(); assert.strictEqual(1, component.element.childNodes.length); - assert.strictEqual('changedFoo', component.element.childNodes[0].textContent); + assert.strictEqual( + 'changedFoo', + component.element.childNodes[0].textContent + ); }); it('should render correctly when recursive children are used', function() { @@ -1996,9 +2193,9 @@ describe('IncrementalDomRenderer', function() { TestComponent.RENDERER = IncrementalDomRenderer; component = new TestComponent(); - var child = component.components.child; - var child2 = component.components.child2; - var child3 = component.components.child3; + let child = component.components.child; + let child2 = component.components.child2; + let child3 = component.components.child3; assert.ok(child instanceof TestChildComponent); assert.ok(child2 instanceof TestChildComponent); assert.ok(child3 instanceof TestChildComponent); @@ -2011,27 +2208,40 @@ describe('IncrementalDomRenderer', function() { assert.strictEqual('CHILD', child2.element.childNodes[0].tagName); assert.strictEqual(child3.element, child2.element.childNodes[0]); assert.strictEqual(1, child3.element.childNodes.length); - assert.strictEqual('Hello World', child2.element.childNodes[0].textContent); + assert.strictEqual( + 'Hello World', + child2.element.childNodes[0].textContent + ); }); - it('should pass same children array when there are no children', function(done) { + it('should pass same children array when there are no children', function( + done + ) { class TestComponent extends Component { render() { IncDom.elementOpen('div'); - IncDom.elementVoid(ChildComponent, null, null, 'ref', 'child', 'foo', this.foo); + IncDom.elementVoid( + ChildComponent, + null, + null, + 'ref', + 'child', + 'foo', + this.foo + ); IncDom.elementClose('div'); } } TestComponent.RENDERER = IncrementalDomRenderer; TestComponent.STATE = { foo: { - value: 'foo' - } + value: 'foo', + }, }; component = new TestComponent(); - var child = component.components.child; - var children = child.children; + let child = component.components.child; + let children = child.children; assert.ok(children); component.foo = 'foo2'; @@ -2061,13 +2271,15 @@ describe('IncrementalDomRenderer', function() { TestComponent.RENDERER = IncrementalDomRenderer; component = new TestComponent(); - var child = component.components.child; - var child2 = component.components.child2; + let child = component.components.child; + let child2 = component.components.child2; assert.strictEqual(child.element, child2.element); assert.notStrictEqual(component.element, child.element); }); - it('should reuse children components when rerendered after update', function(done) { + it('should reuse children components when rerendered after update', function( + done + ) { class TestChildComponent extends Component { render() { IncrementalDOM.elementOpen('div'); @@ -2079,8 +2291,8 @@ describe('IncrementalDomRenderer', function() { TestChildComponent.RENDERER = IncrementalDomRenderer; TestChildComponent.STATE = { foo: { - value: 'foo' - } + value: 'foo', + }, }; class TestComponent extends Component { @@ -2117,7 +2329,7 @@ describe('IncrementalDomRenderer', function() { class TestChildComponent extends Component { getChildContext() { return { - bar: 'bar' + bar: 'bar', }; } @@ -2132,14 +2344,20 @@ describe('IncrementalDomRenderer', function() { class TestComponent extends Component { getChildContext() { return { - foo: 'foo' + foo: 'foo', }; } render() { IncDom.elementOpen('div'); IncDom.elementOpen(TestChildComponent, null, null, 'ref', 'child'); - IncDom.elementVoid(TestGrandChildComponent, null, null, 'ref', 'grandChild'); + IncDom.elementVoid( + TestGrandChildComponent, + null, + null, + 'ref', + 'grandChild' + ); IncDom.elementClose(TestChildComponent); IncDom.elementClose('div'); } @@ -2147,8 +2365,8 @@ describe('IncrementalDomRenderer', function() { TestComponent.RENDERER = IncrementalDomRenderer; component = new TestComponent(); - var child = component.components.child; - var grandChild = component.components.grandChild; + let child = component.components.child; + let grandChild = component.components.grandChild; assert.ok(child instanceof TestChildComponent); assert.ok(grandChild instanceof TestGrandChildComponent); assert.ok(!component.context.foo); @@ -2167,12 +2385,12 @@ describe('IncrementalDomRenderer', function() { } TestChildComponent.RENDERER = IncrementalDomRenderer; - var element = document.createElement('div'); - var tempComp; + let element = document.createElement('div'); + let tempComp; class TestComponent extends Component { getChildContext() { return { - foo: 'foo' + foo: 'foo', }; } @@ -2181,7 +2399,7 @@ describe('IncrementalDomRenderer', function() { } rendered() { - var fn = () => { + let fn = () => { IncDom.elementVoid(TestChildComponent, null, null, 'ref', 'child'); }; tempComp = IncrementalDomRenderer.render(fn, element); @@ -2190,7 +2408,7 @@ describe('IncrementalDomRenderer', function() { TestComponent.RENDERER = IncrementalDomRenderer; component = new TestComponent(); - var child = tempComp.components.child; + let child = tempComp.components.child; assert.ok(child instanceof TestChildComponent); assert.ok(!component.context.foo); assert.ok(!component.context.bar); @@ -2198,11 +2416,13 @@ describe('IncrementalDomRenderer', function() { }); describe('Dispose Unused Sub Components', function() { - it('should dispose sub components that are unused after an update', function(done) { + it('should dispose sub components that are unused after an update', function( + done + ) { class TestComponent extends Component { render() { IncDom.elementOpen('div'); - for (var i = 1; i <= this.count; i++) { + for (let i = 1; i <= this.count; i++) { IncDom.elementVoid('ChildComponent', null, ['ref', 'child' + i]); } IncDom.elementClose('div'); @@ -2211,11 +2431,11 @@ describe('IncrementalDomRenderer', function() { TestComponent.RENDERER = IncrementalDomRenderer; TestComponent.STATE = { count: { - value: 3 - } + value: 3, + }, }; component = new TestComponent(); - var subComps = object.mixin({}, component.components); + let subComps = object.mixin({}, component.components); assert.strictEqual(3, Object.keys(subComps).length); assert.ok(subComps.child1); assert.ok(subComps.child2); @@ -2235,7 +2455,9 @@ describe('IncrementalDomRenderer', function() { }); }); - it('should dispose unused sub component before triggering update rerender', function(done) { + it('should dispose unused sub component before triggering update rerender', function( + done + ) { class TestComponent extends Component { render() { IncDom.elementOpen('div'); @@ -2248,11 +2470,11 @@ describe('IncrementalDomRenderer', function() { TestComponent.RENDERER = IncrementalDomRenderer; TestComponent.STATE = { foo: { - value: 'foo' - } + value: 'foo', + }, }; component = new TestComponent(); - var child = component.components.child; + let child = component.components.child; sinon.spy(child, 'render'); component.foo = 'bar'; @@ -2264,7 +2486,9 @@ describe('IncrementalDomRenderer', function() { }); }); - it('should dispose sub components from "children" that are unused after an update', function(done) { + it('should dispose sub components from "children" that are unused after an update', function( + done + ) { class TestChildComponent extends Component { render() { IncDom.elementOpen('div'); @@ -2275,8 +2499,8 @@ describe('IncrementalDomRenderer', function() { TestChildComponent.RENDERER = IncrementalDomRenderer; TestChildComponent.STATE = { index: { - value: 0 - } + value: 0, + }, }; class TestComponent extends Component { @@ -2290,8 +2514,8 @@ describe('IncrementalDomRenderer', function() { TestComponent.RENDERER = IncrementalDomRenderer; component = new TestComponent(); - var child = component.components.child; - var item1 = component.components.item1; + let child = component.components.child; + let item1 = component.components.item1; assert.ok(item1); assert.ok(!component.components.item2); assert.ok(!item1.isDisposed()); @@ -2306,12 +2530,20 @@ describe('IncrementalDomRenderer', function() { }); }); - it('should dispose sub components from sub components that are unused after a parent update', function(done) { + it('should dispose sub components from sub components that are unused after a parent update', function( + done + ) { class TestChildComponent extends Component { render() { IncDom.elementOpen('div'); if (!this.remove) { - IncDom.elementOpen(ChildComponent, null, null, 'ref', 'innerChild'); + IncDom.elementOpen( + ChildComponent, + null, + null, + 'ref', + 'innerChild' + ); IncDom.elementClose(ChildComponent); } IncDom.elementClose('div'); @@ -2319,24 +2551,30 @@ describe('IncrementalDomRenderer', function() { } TestChildComponent.RENDERER = IncrementalDomRenderer; TestChildComponent.STATE = { - remove: { - } + remove: {}, }; class TestComponent extends Component { render() { - IncDom.elementVoid(TestChildComponent, null, null, 'ref', 'child', 'remove', this.remove); + IncDom.elementVoid( + TestChildComponent, + null, + null, + 'ref', + 'child', + 'remove', + this.remove + ); } } TestComponent.RENDERER = IncrementalDomRenderer; TestComponent.STATE = { - remove: { - } + remove: {}, }; component = new TestComponent(); - var child = component.components.child; - var innerChild = child.components.innerChild; + let child = component.components.child; + let innerChild = child.components.innerChild; assert.ok(innerChild); component.remove = true; @@ -2350,7 +2588,9 @@ describe('IncrementalDomRenderer', function() { }); }); - it('should not remove reusable element from disposed component', function(done) { + it('should not remove reusable element from disposed component', function( + done + ) { class TestChildComponent extends Component { render() { IncDom.elementOpen('child'); @@ -2360,37 +2600,53 @@ describe('IncrementalDomRenderer', function() { } TestChildComponent.STATE = { index: { - value: 0 - } + value: 0, + }, }; TestChildComponent.RENDERER = IncrementalDomRenderer; class TestComponent extends Component { render() { IncDom.elementOpen(TestChildComponent, null, null, 'ref', 'child'); - IncDom.elementVoid(ChildComponent, null, null, 'foo', 'foo1', 'ref', 'grandchild1'); - IncDom.elementVoid(ChildComponent, null, null, 'foo', 'foo2', 'ref', 'grandchild2'); + IncDom.elementVoid( + ChildComponent, + null, + null, + 'foo', + 'foo1', + 'ref', + 'grandchild1' + ); + IncDom.elementVoid( + ChildComponent, + null, + null, + 'foo', + 'foo2', + 'ref', + 'grandchild2' + ); IncDom.elementClose(TestChildComponent); } } TestComponent.RENDERER = IncrementalDomRenderer; component = new TestComponent(); - var child = component.components.child; - var child1 = component.components.grandchild1; + let child = component.components.child; + let child1 = component.components.grandchild1; assert.ok(child1); assert.strictEqual('foo1', child1.foo); assert.strictEqual(child1.element, child.element.childNodes[0]); assert.ok(!child1.isDisposed()); assert.ok(!component.components.foo2); - var child1Element = child1.element; + let child1Element = child1.element; child.index = 1; child.once('stateSynced', function() { assert.ok(!component.components.grandchild1); assert.ok(child1.isDisposed()); - var child2 = component.components.grandchild2; + let child2 = component.components.grandchild2; assert.ok(child2); assert.strictEqual('foo2', child2.foo); assert.strictEqual(child2.element, child.element.childNodes[0]); @@ -2400,7 +2656,9 @@ describe('IncrementalDomRenderer', function() { }); }); - it('should not remove reusable element from disposed component\'s sub components', function(done) { + it('should not remove reusable element from disposed component\'s sub components', function( + done + ) { class TestChildComponent extends Component { render() { IncDom.elementVoid(ChildComponent, null, null, 'ref', 'child'); @@ -2421,12 +2679,11 @@ describe('IncrementalDomRenderer', function() { } TestComponent.RENDERER = IncrementalDomRenderer; TestComponent.STATE = { - switch: { - } + switch: {}, }; component = new TestComponent(); - var child = component.components.child1; + let child = component.components.child1; assert.ok(child instanceof TestChildComponent); assert.strictEqual(child.element, component.element.childNodes[0]); @@ -2443,7 +2700,9 @@ describe('IncrementalDomRenderer', function() { }); }); - it('should not dispose new sub component with same ref as unused sub component', function(done) { + it('should not dispose new sub component with same ref as unused sub component', function( + done + ) { class TestChildComponent extends Component { render() { IncrementalDOM.elementVoid('child'); @@ -2464,16 +2723,15 @@ describe('IncrementalDomRenderer', function() { } TestComponent.RENDERER = IncrementalDomRenderer; TestComponent.STATE = { - switch: { - } + switch: {}, }; component = new TestComponent(); - var child = component.components.child; + let child = component.components.child; assert.ok(child instanceof ChildComponent); component.switch = true; component.once('stateSynced', function() { - var newChild = component.components.child; + let newChild = component.components.child; assert.ok(newChild instanceof TestChildComponent); assert.notStrictEqual(child, newChild); assert.ok(child.isDisposed()); @@ -2483,7 +2741,9 @@ describe('IncrementalDomRenderer', function() { }); }); - it('should not dispose unused sub component if "skipNextChildrenDisposal" is called', function(done) { + it('should not dispose unused sub component if "skipNextChildrenDisposal" is called', function( + done + ) { class TestComponent extends Component { render() { IncDom.elementOpen('div'); @@ -2496,11 +2756,11 @@ describe('IncrementalDomRenderer', function() { TestComponent.RENDERER = IncrementalDomRenderer; TestComponent.STATE = { foo: { - value: 'foo' - } + value: 'foo', + }, }; component = new TestComponent(); - var child = component.components.child; + let child = component.components.child; sinon.spy(child, 'render'); component.foo = 'bar'; @@ -2547,7 +2807,15 @@ describe('IncrementalDomRenderer', function() { core.enableCompatibilityMode(); class TestComponent extends Component { render() { - IncDom.elementVoid(ChildComponent, null, null, 'key', 'keyChild', 'ref', 'refChild'); + IncDom.elementVoid( + ChildComponent, + null, + null, + 'key', + 'keyChild', + 'ref', + 'refChild' + ); } } TestComponent.RENDERER = IncrementalDomRenderer; @@ -2559,11 +2827,10 @@ describe('IncrementalDomRenderer', function() { }); it('should store component references via "key" when renderer is enabled by compatibility mode', function() { - class TestRendererClass extends IncrementalDomRenderer.constructor { - } + class TestRendererClass extends IncrementalDomRenderer.constructor {} const TestRenderer = new TestRendererClass(); core.enableCompatibilityMode({ - renderers: [TestRenderer] + renderers: [TestRenderer], }); class TestComponent extends Component { @@ -2579,12 +2846,11 @@ describe('IncrementalDomRenderer', function() { }); it('should store component references via "key" when renderer is enabled by compatibility mode via its name', function() { - class TestRendererClass extends IncrementalDomRenderer.constructor { - } + class TestRendererClass extends IncrementalDomRenderer.constructor {} const TestRenderer = new TestRendererClass(); TestRenderer.RENDERER_NAME = 'test'; core.enableCompatibilityMode({ - renderers: ['test'] + renderers: ['test'], }); class TestComponent extends Component { @@ -2600,11 +2866,10 @@ describe('IncrementalDomRenderer', function() { }); it('should not store component references via "key" when renderer is not enabled by compatibility mode', function() { - class TestRendererClass extends IncrementalDomRenderer.constructor { - } + class TestRendererClass extends IncrementalDomRenderer.constructor {} const TestRenderer = new TestRendererClass(); core.enableCompatibilityMode({ - renderers: [TestRenderer] + renderers: [TestRenderer], }); class TestComponent extends Component { @@ -2618,40 +2883,45 @@ describe('IncrementalDomRenderer', function() { assert.ok(!component.components.child); }); - describe('Sunset Tests', sunset(function() { - it('should not store component references via "key" on compatibility mode after version 3.x', function() { - core.enableCompatibilityMode(); - class TestComponent extends Component { - render() { - IncDom.elementVoid(ChildComponent, null, null, 'key', 'child'); + describe( + 'Sunset Tests', + sunset(function() { + it('should not store component references via "key" on compatibility mode after version 3.x', function() { + core.enableCompatibilityMode(); + class TestComponent extends Component { + render() { + IncDom.elementVoid(ChildComponent, null, null, 'key', 'child'); + } } - } - TestComponent.RENDERER = IncrementalDomRenderer; + TestComponent.RENDERER = IncrementalDomRenderer; - component = new TestComponent(); - assert.ok(!component.components.child); - }); - })); + component = new TestComponent(); + assert.ok(!component.components.child); + }); + }) + ); }); }); describe('Function - shouldUpdate', function() { - it('should only rerender after state change if "shouldUpdate" returns true', function(done) { + it('should only rerender after state change if "shouldUpdate" returns true', function( + done + ) { class TestComponent extends Component { render() {} shouldUpdate(changes) { - return changes.foo && (changes.foo.prevVal !== changes.foo.newVal); + return changes.foo && changes.foo.prevVal !== changes.foo.newVal; } } TestComponent.RENDERER = IncrementalDomRenderer; TestComponent.STATE = { bar: { - value: 'bar' + value: 'bar', }, foo: { - value: 'foo' - } + value: 'foo', + }, }; component = new TestComponent(); @@ -2677,7 +2947,9 @@ describe('IncrementalDomRenderer', function() { IncrementalDOM.skipNode.restore(); }); - it('should not rerender child component if its "shouldUpdate" returns false', function(done) { + it('should not rerender child component if its "shouldUpdate" returns false', function( + done + ) { class TestChildComponent extends Component { render() { IncDom.elementOpen('span'); @@ -2702,17 +2974,20 @@ describe('IncrementalDomRenderer', function() { TestComponent.RENDERER = IncrementalDomRenderer; TestComponent.STATE = { foo: { - value: 'foo' - } + value: 'foo', + }, }; component = new TestComponent(); - var child = component.components.child; + let child = component.components.child; component.foo = 'foo2'; component.once('stateSynced', function() { assert.strictEqual(1, IncrementalDOM.skipNode.callCount); - assert.strictEqual('foo2', component.element.childNodes[0].textContent); + assert.strictEqual( + 'foo2', + component.element.childNodes[0].textContent + ); assert.strictEqual(child.element, component.element.childNodes[1]); assert.strictEqual('SPAN', child.element.tagName); assert.strictEqual('Child', child.element.textContent); @@ -2721,7 +2996,9 @@ describe('IncrementalDomRenderer', function() { }); }); - it('should correctly reposition child component even if its "shouldUpdate" returns false', function(done) { + it('should correctly reposition child component even if its "shouldUpdate" returns false', function( + done + ) { class TestChildComponent extends Component { render() { IncDom.elementOpen('span'); @@ -2750,12 +3027,11 @@ describe('IncrementalDomRenderer', function() { } TestComponent.RENDERER = IncrementalDomRenderer; TestComponent.STATE = { - wrap: { - } + wrap: {}, }; component = new TestComponent(); - var child = component.components.child; + let child = component.components.child; assert.strictEqual(1, component.element.childNodes.length); assert.strictEqual(child.element, component.element.childNodes[0]); assert.strictEqual('SPAN', child.element.tagName); @@ -2765,14 +3041,19 @@ describe('IncrementalDomRenderer', function() { component.once('stateSynced', function() { assert.strictEqual(1, component.element.childNodes.length); assert.ok(dom.hasClass(component.element.childNodes[0], 'wrapper')); - assert.strictEqual(child.element, component.element.childNodes[0].childNodes[0]); + assert.strictEqual( + child.element, + component.element.childNodes[0].childNodes[0] + ); assert.strictEqual('SPAN', child.element.tagName); assert.strictEqual('Child', child.element.textContent); done(); }); }); - it('should skip child update without error if it had no element before', function(done) { + it('should skip child update without error if it had no element before', function( + done + ) { class TestChildComponent extends Component { render() {} @@ -2793,12 +3074,12 @@ describe('IncrementalDomRenderer', function() { TestComponent.RENDERER = IncrementalDomRenderer; TestComponent.STATE = { foo: { - value: 'foo' - } + value: 'foo', + }, }; component = new TestComponent(); - var child = component.components.child; + let child = component.components.child; sinon.spy(child, 'render'); component.foo = 'foo2'; @@ -2813,7 +3094,9 @@ describe('IncrementalDomRenderer', function() { }); describe('Function - willUpdate', function() { - it('should run "willUpdate" lifecycle method when the component is about to render', function(done) { + it('should run "willUpdate" lifecycle method when the component is about to render', function( + done + ) { class TestComponent extends Component { render() {} } @@ -2821,8 +3104,8 @@ describe('IncrementalDomRenderer', function() { TestComponent.RENDERER = IncrementalDomRenderer; TestComponent.STATE = { foo: { - value: 'foo' - } + value: 'foo', + }, }; component = new TestComponent(); @@ -2836,8 +3119,8 @@ describe('IncrementalDomRenderer', function() { foo: { key: 'foo', newVal: 'foo2', - prevVal: 'foo' - } + prevVal: 'foo', + }, }); done(); @@ -2845,8 +3128,9 @@ describe('IncrementalDomRenderer', function() { }); }); - it('should run "willUpdate" lifecycle method of nested component when it is about to render', function(done) { - const listener = sinon.stub(); + it('should run "willUpdate" lifecycle method of nested component when it is about to render', function( + done + ) { class TestChildComponent extends Component { render() {} } @@ -2854,22 +3138,30 @@ describe('IncrementalDomRenderer', function() { TestChildComponent.RENDERER = IncrementalDomRenderer; TestChildComponent.STATE = { foo: { - value: 'foo' - } + value: 'foo', + }, }; class TestComponent extends Component { render() { IncDom.elementOpen('div'); - IncDom.elementVoid(TestChildComponent, null, null, 'ref', 'child', 'foo', this.foo); + IncDom.elementVoid( + TestChildComponent, + null, + null, + 'ref', + 'child', + 'foo', + this.foo + ); IncDom.elementClose('div'); } } TestComponent.RENDERER = IncrementalDomRenderer; TestComponent.STATE = { foo: { - value: 'foo' - } + value: 'foo', + }, }; component = new TestComponent(); @@ -2884,7 +3176,7 @@ describe('IncrementalDomRenderer', function() { assert.deepEqual(child.willUpdate.args[0][0].foo, { key: 'foo', newVal: 'foo2', - prevVal: 'foo' + prevVal: 'foo', }); done(); @@ -2895,7 +3187,7 @@ describe('IncrementalDomRenderer', function() { describe('Componentless function tags', function() { it('should render componentless function passed as incremental dom tag', function() { - var TestFunction = ({foo}) => { + let TestFunction = ({foo}) => { IncDom.elementOpen('span'); IncDom.text(foo); return IncDom.elementClose('span'); @@ -2918,7 +3210,7 @@ describe('IncrementalDomRenderer', function() { }); it('should render children from componentless function passed as incremental dom tag', function() { - var TestFunction = ({children}) => { + let TestFunction = ({children}) => { IncDom.elementOpen('span'); children.forEach(IncrementalDomRenderer.renderChild); return IncDom.elementClose('span'); @@ -2939,35 +3231,40 @@ describe('IncrementalDomRenderer', function() { assert.strictEqual(0, Object.keys(component.components).length); assert.strictEqual(1, component.element.childNodes.length); assert.strictEqual('SPAN', component.element.childNodes[0].tagName); - assert.strictEqual('children', component.element.childNodes[0].textContent); + assert.strictEqual( + 'children', + component.element.childNodes[0].textContent + ); }); it('should render componentless function via "IncrementalDomRenderer.render"', function() { - var fn = props => { + let fn = props => { IncDom.elementOpen('span', null, null, 'foo', props.foo); IncDom.text('bar'); IncDom.elementClose('span'); }; - var container = document.createElement('span'); + let container = document.createElement('span'); IncrementalDomRenderer.render( fn, { - foo: 'fooValue' + foo: 'fooValue', }, container ); assert.strictEqual(1, container.childNodes.length); - assert.strictEqual('fooValue', container.childNodes[0].getAttribute('foo')); + assert.strictEqual( + 'fooValue', + container.childNodes[0].getAttribute('foo') + ); assert.strictEqual('bar', container.childNodes[0].textContent); }); }); describe('Dispose', function() { it('should remove component with ref from owner', function() { - class Child extends Component { - } + class Child extends Component {} Child.RENDERER = IncrementalDomRenderer; class TestComponent extends Component { @@ -2978,7 +3275,7 @@ describe('IncrementalDomRenderer', function() { TestComponent.RENDERER = IncrementalDomRenderer; component = new TestComponent(); - var child = component.components.child; + let child = component.components.child; child.dispose(); assert.ok(child.isDisposed()); @@ -2986,8 +3283,7 @@ describe('IncrementalDomRenderer', function() { }); it('should not remove different component with same ref from owner', function() { - class Child extends Component { - } + class Child extends Component {} Child.RENDERER = IncrementalDomRenderer; class TestComponent extends Component { @@ -2998,7 +3294,7 @@ describe('IncrementalDomRenderer', function() { TestComponent.RENDERER = IncrementalDomRenderer; component = new TestComponent(); - var child = component.components.child; + let child = component.components.child; component.components.child = new Child(); child.dispose(); @@ -3011,12 +3307,16 @@ describe('IncrementalDomRenderer', function() { describe('IncrementalDomRenderer.isIncDomNode', function() { it('should check if given data is an incremental dom node', function() { assert.ok(!IncrementalDomRenderer.isIncDomNode({})); - assert.ok(!IncrementalDomRenderer.isIncDomNode({ - tag: 'span' - })); - assert.ok(IncrementalDomRenderer.isIncDomNode({ - [CHILD_OWNER]: true - })); + assert.ok( + !IncrementalDomRenderer.isIncDomNode({ + tag: 'span', + }) + ); + assert.ok( + IncrementalDomRenderer.isIncDomNode({ + [CHILD_OWNER]: true, + }) + ); }); }); diff --git a/packages/metal-incremental-dom/test/callArgs.js b/packages/metal-incremental-dom/test/callArgs.js index 8662689a..ce9b4549 100644 --- a/packages/metal-incremental-dom/test/callArgs.js +++ b/packages/metal-incremental-dom/test/callArgs.js @@ -1,29 +1,32 @@ 'use strict'; -import { buildCallFromConfig, buildConfigFromCall } from '../src/callArgs'; +import {buildCallFromConfig, buildConfigFromCall} from '../src/callArgs'; describe('callArgs', function() { it('should build configuration object from incremental dom call', function() { - var config = buildConfigFromCall([ + let config = buildConfigFromCall([ 'span', 'key', ['static1', 'staticVal1', 'static2', 'staticVal2'], 'attr1', - 'attrVal1' + 'attrVal1', ]); - assert.deepEqual({ - key: 'key', - static1: 'staticVal1', - static2: 'staticVal2', - attr1: 'attrVal1' - }, config); + assert.deepEqual( + { + key: 'key', + static1: 'staticVal1', + static2: 'staticVal2', + attr1: 'attrVal1', + }, + config + ); }); it('should build incremental dom call from configuration object', function() { const call = buildCallFromConfig('span', { key: 'key', attr1: 'attrVal1', - attr2: 'attrVal2' + attr2: 'attrVal2', }); assert.equal(7, call.length); diff --git a/packages/metal-incremental-dom/test/changes.js b/packages/metal-incremental-dom/test/changes.js index 1f903d8f..863d7881 100644 --- a/packages/metal-incremental-dom/test/changes.js +++ b/packages/metal-incremental-dom/test/changes.js @@ -1,7 +1,7 @@ 'use strict'; -import { clearChanges, getChanges, trackChanges } from '../src/changes'; -import { getData } from '../src/data'; +import {clearChanges, getChanges, trackChanges} from '../src/changes'; +import {getData} from '../src/data'; import Component from 'metal-component'; describe('changes', function() { @@ -19,15 +19,18 @@ describe('changes', function() { component.visible = false; const changes = getChanges(component); - assert.deepEqual({ - props: { - visible: { - key: 'visible', - newVal: false, - prevVal: true - } - } - }, changes); + assert.deepEqual( + { + props: { + visible: { + key: 'visible', + newVal: false, + prevVal: true, + }, + }, + }, + changes + ); }); it('should clear changes for a given component', function() { diff --git a/packages/metal-incremental-dom/test/children/children.js b/packages/metal-incremental-dom/test/children/children.js index edf24ce6..6afff046 100644 --- a/packages/metal-incremental-dom/test/children/children.js +++ b/packages/metal-incremental-dom/test/children/children.js @@ -1,15 +1,20 @@ 'use strict'; import dom from 'metal-dom'; -import { sunset } from '../../../../test-utils'; -import { captureChildren, getOwner, renderChildTree, CHILD_OWNER } from '../../src/children/children'; +import {sunset} from '../../../../test-utils'; +import { + captureChildren, + getOwner, + renderChildTree, + CHILD_OWNER, +} from '../../src/children/children'; describe('children', function() { it('should capture children calls to incremental dom', function(done) { captureChildren({}, function(tree) { assert.strictEqual(1, tree.props.children.length); - var node = tree.props.children[0]; + let node = tree.props.children[0]; assert.ok(!node.text); assert.strictEqual('span', node.tag); assert.ok(node.props); @@ -32,10 +37,7 @@ describe('children', function() { it('should return the captured tree\'s given owner object', function(done) { const owner = {}; captureChildren(owner, function(tree) { - assert.strictEqual( - owner, - getOwner(tree.props.children[0]) - ); + assert.strictEqual(owner, getOwner(tree.props.children[0])); done(); }); @@ -43,22 +45,21 @@ describe('children', function() { IncrementalDOM.elementClose('div'); }); - it('should store args for text nodes when they contain more than just the text', function(done) { + it('should store args for text nodes when they contain more than just the text', function( + done + ) { captureChildren({}, function(tree) { - var node = tree.props.children[0]; + let node = tree.props.children[0]; assert.strictEqual('No args', node.text); assert.ok(!node.args); node = tree.props.children[1]; assert.strictEqual('With args', node.text); - assert.deepEqual([ - node.text, - formatFn - ], node.args); + assert.deepEqual([node.text, formatFn], node.args); done(); }); - var formatFn = val => val; + const formatFn = val => val; IncrementalDOM.text('No args'); IncrementalDOM.text('With args', formatFn); IncrementalDOM.elementClose('div'); @@ -71,7 +72,7 @@ describe('children', function() { origElementOpen = IncrementalDOM.elementOpen; IncrementalDOM.elementOpen = function(...args) { args[0] = args[0].tag; - origElementOpen.apply(null, args); + origElementOpen(...args); }; }); @@ -80,7 +81,7 @@ describe('children', function() { }); it('should render captured children via incremental dom', function() { - var element = document.createElement('div'); + let element = document.createElement('div'); IncrementalDOM.patch(element, () => { renderChildTree({ @@ -89,19 +90,19 @@ describe('children', function() { children: [ { args: ['Hello World'], - text: 'Hello World' - } + text: 'Hello World', + }, ], class: 'test', foo: 'bar', - key: 'key' - } + key: 'key', + }, }); }); assert.strictEqual(1, element.childNodes.length); - var spanElement = element.childNodes[0]; + let spanElement = element.childNodes[0]; assert.strictEqual('SPAN', spanElement.tagName); assert.ok(dom.hasClass(spanElement, 'test')); assert.strictEqual('bar', spanElement.getAttribute('foo')); @@ -110,7 +111,7 @@ describe('children', function() { }); it('should skip rendering children node when skipNode function returns true', function() { - var element = document.createElement('div'); + let element = document.createElement('div'); function skipNode(node) { if (node.props && node.props.id === 'skip') { @@ -118,52 +119,60 @@ describe('children', function() { } } IncrementalDOM.patch(element, () => { - renderChildTree({ - tag: 'span', - props: { - children: [ - { - tag: 'span', - props: { - id: 'beforeSkip' - } - }, - { - tag: 'span', - props: { - id: 'skip' - } - }, - { - tag: 'span', - props: { - id: 'afterSkip' - } - } - ], - id: 'parent' - } - }, skipNode); + renderChildTree( + { + tag: 'span', + props: { + children: [ + { + tag: 'span', + props: { + id: 'beforeSkip', + }, + }, + { + tag: 'span', + props: { + id: 'skip', + }, + }, + { + tag: 'span', + props: { + id: 'afterSkip', + }, + }, + ], + id: 'parent', + }, + }, + skipNode + ); }); assert.strictEqual(1, element.childNodes.length); - var child = element.childNodes[0]; + let child = element.childNodes[0]; assert.strictEqual(2, child.childNodes.length); assert.strictEqual('beforeSkip', child.childNodes[0].id); assert.strictEqual('afterSkip', child.childNodes[1].id); }); - it('should render text nodes that have been changed after capture', function(done) { + it('should render text nodes that have been changed after capture', function( + done + ) { captureChildren({}, function(tree) { - var element = document.createElement('div'); + let element = document.createElement('div'); tree.props.children[0].text = 'New Text'; IncrementalDOM.patch(element, () => { renderChildTree(tree.props.children[0]); }); assert.strictEqual(1, element.childNodes.length); - assert.strictEqual('New Text Formatted', element.childNodes[0].textContent); + assert.strictEqual( + 'New Text Formatted', + element.childNodes[0].textContent + ); done(); }); @@ -172,12 +181,14 @@ describe('children', function() { }); }); - it('should keep original renderer for children that have been recaptured by another1', function(done) { - var renderer1 = {}; - var renderer2 = {}; + it('should keep original renderer for children that have been recaptured by another1', function( + done + ) { + let renderer1 = {}; + let renderer2 = {}; captureChildren(renderer2, function(tree) { - var element = tree.props.children[0]; + let element = tree.props.children[0]; assert.strictEqual('div', element.tag); assert.strictEqual(renderer2, getOwner(element)); assert.strictEqual(1, element.props.children.length); @@ -200,28 +211,33 @@ describe('children', function() { children: [ { text: 'Hello World', - [CHILD_OWNER]: renderer1 + [CHILD_OWNER]: renderer1, }, - ] + ], }, - [CHILD_OWNER]: renderer1 + [CHILD_OWNER]: renderer1, }); IncrementalDOM.elementClose('div'); IncrementalDOM.elementClose('div'); }); - describe('Sunset Tests', sunset(function() { - it('should not have "config" object inside each child after version 3.x', function(done) { - captureChildren({}, function(tree) { - assert.strictEqual(1, tree.props.children.length); + describe( + 'Sunset Tests', + sunset(function() { + it('should not have "config" object inside each child after version 3.x', function( + done + ) { + captureChildren({}, function(tree) { + assert.strictEqual(1, tree.props.children.length); + + let node = tree.props.children[0]; + assert.ok(!node.config, 'Remove "config" for version 3.x'); + done(); + }); - var node = tree.props.children[0]; - assert.ok(!node.config, 'Remove "config" for version 3.x'); - done(); + IncrementalDOM.elementVoid('span', null, null, 'foo', 'bar'); + IncrementalDOM.elementClose('div'); }); - - IncrementalDOM.elementVoid('span', null, null, 'foo', 'bar'); - IncrementalDOM.elementClose('div'); - }); - })); + }) + ); }); diff --git a/packages/metal-incremental-dom/test/cleanup/unused.js b/packages/metal-incremental-dom/test/cleanup/unused.js index db9ba3c3..82a03987 100644 --- a/packages/metal-incremental-dom/test/cleanup/unused.js +++ b/packages/metal-incremental-dom/test/cleanup/unused.js @@ -2,12 +2,12 @@ import Component from 'metal-component'; import IncrementalDomRenderer from '../../src/IncrementalDomRenderer'; -import { disposeUnused, schedule } from '../../src/cleanup/unused'; -import { getData } from '../../src/data'; +import {disposeUnused, schedule} from '../../src/cleanup/unused'; +import {getData} from '../../src/data'; describe('unused', function() { - var comp; - var grandchild; + let comp; + let grandchild; beforeEach(function() { class GrandChild extends Component { @@ -43,7 +43,7 @@ describe('unused', function() { }); it('should dispose scheduled components', function() { - var comps = [comp.components.child1, comp.components.child2]; + let comps = [comp.components.child1, comp.components.child2]; schedule(comps); disposeUnused(); @@ -52,7 +52,7 @@ describe('unused', function() { }); it('should not dispose scheduled components that have received a new parent', function() { - var comps = [comp.components.child1, comp.components.child2]; + let comps = [comp.components.child1, comp.components.child2]; schedule(comps); getData(comps[0]).parent = comp; disposeUnused(); @@ -62,7 +62,7 @@ describe('unused', function() { }); it('should not dispose scheduled components that have been disposed before scheduled', function() { - var comps = [comp.components.child1, comp.components.child2]; + let comps = [comp.components.child1, comp.components.child2]; comps[0].dispose(); schedule(comps); sinon.spy(comps[0], 'dispose'); @@ -74,7 +74,7 @@ describe('unused', function() { }); it('should not dispose scheduled components that have been disposed after scheduled', function() { - var comps = [comp.components.child1, comp.components.child2]; + let comps = [comp.components.child1, comp.components.child2]; schedule(comps); comps[0].dispose(); sinon.spy(comps[0], 'dispose'); @@ -90,7 +90,7 @@ describe('unused', function() { disposeUnused(); }); - var comps = [comp.components.child1]; + let comps = [comp.components.child1]; schedule(comps); assert.doesNotThrow(() => disposeUnused()); @@ -98,7 +98,7 @@ describe('unused', function() { }); it('should not throw error when disposing component that has an owner that was previously disposed', function() { - var comps = [comp.components.child2, grandchild]; + let comps = [comp.components.child2, grandchild]; schedule(comps); assert.doesNotThrow(() => disposeUnused()); }); diff --git a/packages/metal-incremental-dom/test/data.js b/packages/metal-incremental-dom/test/data.js index 7ab02534..2ca549bb 100644 --- a/packages/metal-incremental-dom/test/data.js +++ b/packages/metal-incremental-dom/test/data.js @@ -1,6 +1,6 @@ 'use strict'; -import { clearData, getData } from '../src/data'; +import {clearData, getData} from '../src/data'; describe('data', function() { it('should return an empty object on the first "getData" call for an object', function() { diff --git a/packages/metal-incremental-dom/test/html/HTML2IncDom.js b/packages/metal-incremental-dom/test/html/HTML2IncDom.js index 9ca88ce1..f58aa852 100644 --- a/packages/metal-incremental-dom/test/html/HTML2IncDom.js +++ b/packages/metal-incremental-dom/test/html/HTML2IncDom.js @@ -4,36 +4,36 @@ import HTML2IncDom from '../../src/html/HTML2IncDom'; describe('HTML2IncDom', function() { it('should render html inside element via incremental dom', function() { - var element = document.createElement('div'); - var htmlStr = '
Foo
'; + let element = document.createElement('div'); + let htmlStr = '
Foo
'; IncrementalDOM.patch(element, () => HTML2IncDom.run(htmlStr)); assert.strictEqual(htmlStr, element.innerHTML); }); it('should render link element inside its span parent via incremental dom', function() { - var element = document.createElement('div'); - var htmlStr = 'Foo'; + let element = document.createElement('div'); + let htmlStr = 'Foo'; IncrementalDOM.patch(element, () => HTML2IncDom.run(htmlStr)); assert.strictEqual(htmlStr, element.innerHTML); }); it('should render escaped html inside element via incremental dom', function() { - var element = document.createElement('div'); + let element = document.createElement('div'); IncrementalDOM.patch(element, () => HTML2IncDom.run(''Foo'')); assert.strictEqual('\'Foo\'', element.textContent); }); it('should render void elements from html via incremental dom', function() { - var element = document.createElement('div'); - var htmlStr = ''; + let element = document.createElement('div'); + let htmlStr = ''; IncrementalDOM.patch(element, () => HTML2IncDom.run(htmlStr)); assert.strictEqual(htmlStr, element.innerHTML); }); it('should build function for rendering html via incremental dom', function() { - var element = document.createElement('div'); - var htmlStr = '
Foo
'; - var fn = HTML2IncDom.buildFn(htmlStr); + let element = document.createElement('div'); + let htmlStr = '
Foo
'; + let fn = HTML2IncDom.buildFn(htmlStr); assert.strictEqual(0, element.childNodes.length); IncrementalDOM.patch(element, fn); @@ -52,10 +52,13 @@ describe('HTML2IncDom', function() { handlers.end('div'); }); - var element = document.createElement('div'); - var htmlStr = '
Foo
'; + let element = document.createElement('div'); + let htmlStr = '
Foo
'; IncrementalDOM.patch(element, () => HTML2IncDom.run(htmlStr)); - assert.strictEqual('
Foo-CustomParser
', element.innerHTML); + assert.strictEqual( + '
Foo-CustomParser
', + element.innerHTML + ); }); }); }); diff --git a/packages/metal-incremental-dom/test/incremental-dom-aop.js b/packages/metal-incremental-dom/test/incremental-dom-aop.js index adff6fad..27282653 100644 --- a/packages/metal-incremental-dom/test/incremental-dom-aop.js +++ b/packages/metal-incremental-dom/test/incremental-dom-aop.js @@ -2,10 +2,14 @@ import core from 'metal'; import dom from 'metal-dom'; -import { getOriginalFns, startInterception, stopInterception } from '../src/incremental-dom-aop'; +import { + getOriginalFns, + startInterception, + stopInterception, +} from '../src/incremental-dom-aop'; describe('incremental-dom-aop', function() { - var element; + let element; beforeEach(function() { element = document.createElement('div'); @@ -19,7 +23,7 @@ describe('incremental-dom-aop', function() { describe('Original Functions', function() { it('should return the original functions', function() { - var originalFns = getOriginalFns(); + let originalFns = getOriginalFns(); assert.ok(originalFns); assert.ok(originalFns.attr); assert.ok(originalFns.attributes); @@ -34,9 +38,9 @@ describe('incremental-dom-aop', function() { describe('elementOpen', function() { it('should intercept elementOpen calls with specified function', function() { - var fn = sinon.stub(); + let fn = sinon.stub(); startInterception({ - elementOpen: fn + elementOpen: fn, }); IncrementalDOM.elementOpen('div', 'key', 'statics', 'name', 'value'); @@ -49,9 +53,9 @@ describe('incremental-dom-aop', function() { }); it('should stop intercepting elementOpen calls', function() { - var fn = sinon.stub(); + let fn = sinon.stub(); startInterception({ - elementOpen: fn + elementOpen: fn, }); stopInterception(); @@ -66,11 +70,11 @@ describe('incremental-dom-aop', function() { describe('elementVoid', function() { it('should intercept elementOpen and elementClose from elementVoid calls with specified function', function() { - var openFn = sinon.stub(); - var closeFn = sinon.stub(); + let openFn = sinon.stub(); + let closeFn = sinon.stub(); startInterception({ elementClose: closeFn, - elementOpen: openFn + elementOpen: openFn, }); IncrementalDOM.elementVoid('div', 'key', 'statics', 'name', 'value'); @@ -84,9 +88,9 @@ describe('incremental-dom-aop', function() { }); it('should stop intercepting elementOpen from elementVoid calls', function() { - var fn = sinon.stub(); + let fn = sinon.stub(); startInterception({ - elementOpen: fn + elementOpen: fn, }); stopInterception(); @@ -97,9 +101,9 @@ describe('incremental-dom-aop', function() { describe('elementOpenStart/elementOpenEnd', function() { it('should intercept elementOpen from elementOpenEnd calls with specified function', function() { - var fn = sinon.stub(); + let fn = sinon.stub(); startInterception({ - elementOpen: fn + elementOpen: fn, }); IncrementalDOM.elementOpenStart('div', 'key', 'statics'); @@ -117,9 +121,9 @@ describe('incremental-dom-aop', function() { }); it('should stop intercepting elementOpen from elementOpenEnd calls', function() { - var fn = sinon.stub(); + let fn = sinon.stub(); startInterception({ - elementOpen: fn + elementOpen: fn, }); stopInterception(); @@ -134,9 +138,9 @@ describe('incremental-dom-aop', function() { describe('text', function() { it('should intercept "text" calls with specified function', function() { - var fn = sinon.stub(); + let fn = sinon.stub(); startInterception({ - text: fn + text: fn, }); IncrementalDOM.text('foo'); @@ -145,9 +149,9 @@ describe('incremental-dom-aop', function() { }); it('should stop intercepting "text" calls', function() { - var fn = sinon.stub(); + let fn = sinon.stub(); startInterception({ - text: fn + text: fn, }); stopInterception(); @@ -158,13 +162,17 @@ describe('incremental-dom-aop', function() { describe('attributes', function() { it('should intercept attribute calls with specified function', function() { - var fn = sinon.stub(); + let fn = sinon.stub(); startInterception({ - attributes: fn + attributes: fn, }); - var element = document.createElement('div'); - IncrementalDOM.attributes[IncrementalDOM.symbols.default](element, 'name', 'value'); + let element = document.createElement('div'); + IncrementalDOM.attributes[IncrementalDOM.symbols.default]( + element, + 'name', + 'value' + ); assert.strictEqual(1, fn.callCount); assert.ok(core.isElement(fn.args[0][0])); @@ -173,13 +181,17 @@ describe('incremental-dom-aop', function() { }); it('should stop intercepting attribute calls', function() { - var fn = sinon.stub(); + let fn = sinon.stub(); startInterception({ - attributes: fn + attributes: fn, }); stopInterception(); - IncrementalDOM.attributes[IncrementalDOM.symbols.default](element, 'name', 'value'); + IncrementalDOM.attributes[IncrementalDOM.symbols.default]( + element, + 'name', + 'value' + ); assert.strictEqual(0, fn.callCount); }); }); @@ -190,13 +202,13 @@ describe('incremental-dom-aop', function() { }); it('should use last registered function for intercepting', function() { - var fn = sinon.stub(); + let fn = sinon.stub(); startInterception({ - elementOpen: fn + elementOpen: fn, }); - var fn2 = sinon.stub(); + let fn2 = sinon.stub(); startInterception({ - elementOpen: fn2 + elementOpen: fn2, }); IncrementalDOM.elementOpen('div'); @@ -205,13 +217,13 @@ describe('incremental-dom-aop', function() { }); it('should revert to previous registered function when stopping interception', function() { - var fn = sinon.stub(); + let fn = sinon.stub(); startInterception({ - elementOpen: fn + elementOpen: fn, }); - var fn2 = sinon.stub(); + let fn2 = sinon.stub(); startInterception({ - elementOpen: fn2 + elementOpen: fn2, }); stopInterception(); diff --git a/packages/metal-incremental-dom/test/render/attributes.js b/packages/metal-incremental-dom/test/render/attributes.js index 7a7bc536..ca67ad53 100644 --- a/packages/metal-incremental-dom/test/render/attributes.js +++ b/packages/metal-incremental-dom/test/render/attributes.js @@ -1,7 +1,10 @@ 'use strict'; import {isFunction} from 'metal'; -import { applyAttribute, convertListenerNamesToFns } from '../../src/render/attributes'; +import { + applyAttribute, + convertListenerNamesToFns, +} from '../../src/render/attributes'; import dom from 'metal-dom'; import Component from 'metal-component'; @@ -52,13 +55,12 @@ describe('attributes', function() { describe('listeners', function() { it('should register the method name inside the listener', function() { - class TestComponent extends Component { - } + class TestComponent extends Component {} TestComponent.prototype.handleClick = function() {}; component = new TestComponent(); let config = { - 'data-onclick': 'handleClick' + 'data-onclick': 'handleClick', }; convertListenerNamesToFns(component, config); @@ -66,8 +68,7 @@ describe('attributes', function() { }); it('should attach listeners functions passed to "data-on" attributes', function() { - class TestComponent extends Component { - } + class TestComponent extends Component {} component = new TestComponent(); const element = document.createElement('div'); @@ -81,8 +82,7 @@ describe('attributes', function() { }); it('should attach listeners functions passed to "on" attributes', function() { - class TestComponent extends Component { - } + class TestComponent extends Component {} component = new TestComponent(); const element = document.createElement('div'); @@ -96,8 +96,7 @@ describe('attributes', function() { }); it('should not set attribute for listener references on elements', function() { - class TestComponent extends Component { - } + class TestComponent extends Component {} component = new TestComponent(); const element = document.createElement('div'); @@ -119,11 +118,10 @@ describe('attributes', function() { dom.registerCustomEvent('test-event', { delegate: true, handler: (callback, event) => callback(event), - originalEvent: 'click' + originalEvent: 'click', }); - class TestComponent extends Component { - } + class TestComponent extends Component {} component = new TestComponent(); const element = document.createElement('div'); @@ -139,11 +137,10 @@ describe('attributes', function() { dom.registerCustomEvent('test-event', { delegate: true, handler: (callback, event) => callback(event), - originalEvent: 'click' + originalEvent: 'click', }); - class TestComponent extends Component { - } + class TestComponent extends Component {} component = new TestComponent(); const element = document.createElement('div'); @@ -156,8 +153,7 @@ describe('attributes', function() { }); it('should remove unused inline listeners when attributes are removed', function() { - class TestComponent extends Component { - } + class TestComponent extends Component {} component = new TestComponent(); const element = document.createElement('div'); @@ -171,8 +167,7 @@ describe('attributes', function() { }); it('should replace inline listeners when attributes values change', function() { - class TestComponent extends Component { - } + class TestComponent extends Component {} TestComponent.prototype.handleClick = sinon.stub(); TestComponent.prototype.handleClick2 = sinon.stub(); component = new TestComponent(); diff --git a/packages/metal-isomorphic/test/fixtures/MyComponent.js b/packages/metal-isomorphic/test/fixtures/MyComponent.js index decce20d..e897c26f 100644 --- a/packages/metal-isomorphic/test/fixtures/MyComponent.js +++ b/packages/metal-isomorphic/test/fixtures/MyComponent.js @@ -3,15 +3,14 @@ import Soy from 'metal-soy'; import templates from './MyComponent.soy.js'; -class MyComponent extends Component { -} +class MyComponent extends Component {} MyComponent.STATE = { message: { - value: '' - } + value: '', + }, }; Soy.register(MyComponent, templates); -export default MyComponent; \ No newline at end of file +export default MyComponent; diff --git a/packages/metal-isomorphic/test/fixtures/MyJSXComponent.js b/packages/metal-isomorphic/test/fixtures/MyJSXComponent.js index 928702b2..28d13568 100644 --- a/packages/metal-isomorphic/test/fixtures/MyJSXComponent.js +++ b/packages/metal-isomorphic/test/fixtures/MyJSXComponent.js @@ -10,8 +10,8 @@ class MyJSXComponent extends JSXComponent { MyJSXComponent.PROPS = { message: { - value: '' - } + value: '', + }, }; -export default MyJSXComponent; \ No newline at end of file +export default MyJSXComponent; diff --git a/packages/metal-isomorphic/test/isomorphic.js b/packages/metal-isomorphic/test/isomorphic.js index 5ae3c923..23601213 100644 --- a/packages/metal-isomorphic/test/isomorphic.js +++ b/packages/metal-isomorphic/test/isomorphic.js @@ -1,12 +1,12 @@ import Component from 'metal-component'; import MyComponent from './fixtures/MyComponent'; import MyJSXComponent from './fixtures/MyJSXComponent'; -import { assert } from 'chai'; +import {assert} from 'chai'; describe('Isomorphic Rendering', () => { it('should render soy component to string', () => { const htmlString = Component.renderToString(MyComponent, { - message: 'Hello, Soy!' + message: 'Hello, Soy!', }); assert.equal(htmlString, '
Hello, Soy!
'); @@ -14,7 +14,7 @@ describe('Isomorphic Rendering', () => { it('should render jsx component to string', () => { const htmlString = Component.renderToString(MyJSXComponent, { - message: 'Hello, JSX!' + message: 'Hello, JSX!', }); assert.equal(htmlString, '
Hello, JSX!
'); diff --git a/packages/metal-jsx/.eslintrc.json b/packages/metal-jsx/.eslintrc similarity index 66% rename from packages/metal-jsx/.eslintrc.json rename to packages/metal-jsx/.eslintrc index 81c52662..5f83befd 100644 --- a/packages/metal-jsx/.eslintrc.json +++ b/packages/metal-jsx/.eslintrc @@ -5,8 +5,5 @@ }, "plugins": [ "react" - ], - "rules": { - "react/jsx-uses-vars": [2] - } + ] } diff --git a/packages/metal-jsx/package-lock.json b/packages/metal-jsx/package-lock.json index b45b5193..91563676 100644 --- a/packages/metal-jsx/package-lock.json +++ b/packages/metal-jsx/package-lock.json @@ -64,7 +64,7 @@ "lodash": "4.17.4", "minimatch": "3.0.4", "path-is-absolute": "1.0.1", - "private": "0.1.7", + "private": "0.1.8", "slash": "1.0.0", "source-map": "0.5.7" } @@ -521,9 +521,9 @@ } }, "babel-preset-env": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/babel-preset-env/-/babel-preset-env-1.6.0.tgz", - "integrity": "sha512-OVgtQRuOZKckrILgMA5rvctvFZPv72Gua9Rt006AiPoB0DJKGN07UmaQA+qRrYgK71MVct8fFhT0EyNWYorVew==", + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/babel-preset-env/-/babel-preset-env-1.6.1.tgz", + "integrity": "sha512-W6VIyA6Ch9ePMI7VptNn2wBM6dbG0eSz25HEiL40nQXCsXGTGZSTZu1Iap+cj3Q0S5a7T9+529l/5Bkvd+afNA==", "requires": { "babel-plugin-check-es2015-constants": "6.22.0", "babel-plugin-syntax-trailing-function-commas": "6.22.0", @@ -552,7 +552,7 @@ "babel-plugin-transform-es2015-unicode-regex": "6.24.1", "babel-plugin-transform-exponentiation-operator": "6.24.1", "babel-plugin-transform-regenerator": "6.26.0", - "browserslist": "2.5.1", + "browserslist": "2.8.0", "invariant": "2.2.2", "semver": "5.4.1" } @@ -647,18 +647,18 @@ } }, "browserslist": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-2.5.1.tgz", - "integrity": "sha512-jAvM2ku7YDJ+leAq3bFH1DE0Ylw+F+EQDq4GkqZfgPEqpWYw9ofQH85uKSB9r3Tv7XDbfqVtE+sdvKJW7IlPJA==", + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-2.8.0.tgz", + "integrity": "sha512-iiWHM1Et6Q4TQpB7Ar6pxuM3TNMXasVJY4Y/oh3q38EwR3Z+IdZ9MyVf7PI4MJFB4xpwMcZgs9bEUnPG2E3TCA==", "requires": { - "caniuse-lite": "1.0.30000746", - "electron-to-chromium": "1.3.25" + "caniuse-lite": "1.0.30000760", + "electron-to-chromium": "1.3.27" } }, "caniuse-lite": { - "version": "1.0.30000746", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000746.tgz", - "integrity": "sha1-xk+Vo5Jc/TAgejCO12wa6W6gnqA=" + "version": "1.0.30000760", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000760.tgz", + "integrity": "sha1-7HIDlXQvHH7IlH/W3SYE53qPmP8=" }, "chalk": { "version": "1.1.3", @@ -709,9 +709,9 @@ } }, "electron-to-chromium": { - "version": "1.3.25", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.25.tgz", - "integrity": "sha1-RTshAJg20Jl9hgNWAf9srkeRxGA=" + "version": "1.3.27", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.27.tgz", + "integrity": "sha1-eOy4o5kGYYe7N07t412ccFZagD0=" }, "escape-string-regexp": { "version": "1.0.5", @@ -901,9 +901,9 @@ "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" }, "private": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/private/-/private-0.1.7.tgz", - "integrity": "sha1-aM5eih7woju1cMwoU3tTMqumPvE=" + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/private/-/private-0.1.8.tgz", + "integrity": "sha512-VvivMrbvd2nKkiG38qjULzlc+4Vx4wm/whI9pQD35YrARNnhxeiRktSOhSukRLFNlzg6Br/cJPet5J/u19r/mg==" }, "regenerate": { "version": "1.3.3", @@ -922,7 +922,7 @@ "requires": { "babel-runtime": "6.26.0", "babel-types": "6.26.0", - "private": "0.1.7" + "private": "0.1.8" } }, "regexpu-core": { diff --git a/packages/metal-jsx/src/DangerouslySetHTML.js b/packages/metal-jsx/src/DangerouslySetHTML.js index a29de329..eb5531a8 100644 --- a/packages/metal-jsx/src/DangerouslySetHTML.js +++ b/packages/metal-jsx/src/DangerouslySetHTML.js @@ -1,7 +1,7 @@ 'use strict'; import Component from './JSXComponent'; -import { Config } from 'metal-state'; +import {Config} from 'metal-state'; /** * JSXComponent that renders html passed in. diff --git a/packages/metal-jsx/src/JSXComponent.js b/packages/metal-jsx/src/JSXComponent.js index 6c4cc840..6bbef471 100644 --- a/packages/metal-jsx/src/JSXComponent.js +++ b/packages/metal-jsx/src/JSXComponent.js @@ -1,7 +1,7 @@ 'use strict'; import './iDOMHelpers'; -import { object } from 'metal'; +import {object} from 'metal'; import Component from 'metal-component'; import IncrementalDomRenderer from 'metal-incremental-dom'; import JSXDataManager from './JSXDataManager'; @@ -50,7 +50,13 @@ class JSXComponent extends Component { * @return {Object} Object containing props */ otherProps() { - const removeKeys = [...this.getDataManager().getPropsInstance(this).getStateKeys(), 'key', 'ref']; + const removeKeys = [ + ...this.getDataManager() + .getPropsInstance(this) + .getStateKeys(), + 'key', + 'ref', + ]; const retObj = object.mixin({}, this.props); diff --git a/packages/metal-jsx/src/JSXDataManager.js b/packages/metal-jsx/src/JSXDataManager.js index 2cdd1ef0..087abdc7 100644 --- a/packages/metal-jsx/src/JSXDataManager.js +++ b/packages/metal-jsx/src/JSXDataManager.js @@ -1,9 +1,12 @@ 'use strict'; -import { getStaticProperty, object } from 'metal'; -import { ComponentDataManager } from 'metal-component'; +import {getStaticProperty, object} from 'metal'; +import {ComponentDataManager} from 'metal-component'; import State from 'metal-state'; +/** + * DataManager for JSX + */ class JSXDataManager extends ComponentDataManager.constructor { /** * Manually adds props that weren't configured via `PROPS`. @@ -36,16 +39,18 @@ class JSXDataManager extends ComponentDataManager.constructor { const data = this.getManagerData(comp); data.props_ = new State(comp.getInitialConfig(), comp.props, comp); - data.props_.configState(object.mixin( - {}, - config, - getStaticProperty(ctor, 'PROPS', State.mergeState) - )); + data.props_.configState( + object.mixin( + {}, + config, + getStaticProperty(ctor, 'PROPS', State.mergeState) + ) + ); this.addUnconfiguredProps_(comp, data.props_, comp.getInitialConfig()); data.state_ = new State({}, comp.state, comp); data.state_.setEventData({ - type: 'state' + type: 'state', }); data.state_.configState(State.getStateStatic(ctor)); } @@ -104,7 +109,7 @@ class JSXDataManager extends ComponentDataManager.constructor { } const props = this.getManagerData(component).props_; - ComponentDataManager.replaceNonInternal.call(this, component, data, props); + ComponentDataManager.replaceNonInternal.call(this, component, data, props); // eslint-disable-line this.addUnconfiguredProps_(component, props, data); if (component.propsChanged) { component.propsChanged(prevProps); diff --git a/packages/metal-jsx/src/JSXRenderer.js b/packages/metal-jsx/src/JSXRenderer.js index f3eb183b..d54b71dd 100644 --- a/packages/metal-jsx/src/JSXRenderer.js +++ b/packages/metal-jsx/src/JSXRenderer.js @@ -1,6 +1,6 @@ 'use strict'; -import { isDefAndNotNull } from 'metal'; +import {isDefAndNotNull} from 'metal'; import IncrementalDomRenderer from 'metal-incremental-dom'; const COUNT_PROP = '__metalJsxCount'; @@ -53,6 +53,7 @@ class JSXRenderer extends IncrementalDomRenderer.constructor { /** * Increments the number of children in the current element. + * @return {number} */ incElementCount() { const node = IncrementalDOM.currentElement(); diff --git a/packages/metal-jsx/src/all/jsx.js b/packages/metal-jsx/src/all/jsx.js index a267d2fb..141b5c58 100644 --- a/packages/metal-jsx/src/all/jsx.js +++ b/packages/metal-jsx/src/all/jsx.js @@ -1,8 +1,8 @@ 'use strict'; -import { validators, Config } from 'metal-state'; +import {validators, Config} from 'metal-state'; import DangerouslySetHTML from '../DangerouslySetHTML'; import JSXComponent from '../JSXComponent'; export default JSXComponent; -export { DangerouslySetHTML, validators, Config, JSXComponent }; +export {DangerouslySetHTML, validators, Config, JSXComponent}; diff --git a/packages/metal-jsx/src/iDOMHelpers.js b/packages/metal-jsx/src/iDOMHelpers.js index f931e890..1dd7756b 100644 --- a/packages/metal-jsx/src/iDOMHelpers.js +++ b/packages/metal-jsx/src/iDOMHelpers.js @@ -9,7 +9,10 @@ import JSXRenderer from './JSXRenderer'; * https://github.com/jridgewell/babel-plugin-incremental-dom#runtime */ -const scope = (typeof exports !== 'undefined' && typeof global !== 'undefined') ? global : window; +const scope = + typeof exports !== 'undefined' && typeof global !== 'undefined' + ? global + : window; scope.iDOMHelpers = scope.iDOMHelpers || {}; @@ -27,16 +30,21 @@ scope.iDOMHelpers.forOwn = function(object, iterator) { }; scope.iDOMHelpers.jsxWrapper = function(elementClosure, args) { - const wrapper = args ? function() { - return elementClosure.apply(this, args); - } : elementClosure; + const wrapper = args + ? function() { + return elementClosure.apply(this, args); // eslint-disable-line + } + : elementClosure; wrapper.__jsxDOMWrapper = true; return wrapper; }; scope.iDOMHelpers.renderArbitrary = function(child) { const type = typeof child; - if (type === 'number' || (type === 'string' || child && child instanceof String)) { + if ( + type === 'number' || + (type === 'string' || (child && child instanceof String)) + ) { IncrementalDOM.text(child); } else if (type === 'function' && child.__jsxDOMWrapper) { child(); diff --git a/packages/metal-jsx/test/.eslintrc b/packages/metal-jsx/test/.eslintrc new file mode 100644 index 00000000..28b22103 --- /dev/null +++ b/packages/metal-jsx/test/.eslintrc @@ -0,0 +1,23 @@ +{ + "env": { + "mocha": true + }, + "globals": { + "assert": true, + "sinon": true + }, + "parserOptions": { + "ecmaFeatures": { + "jsx": true + } + }, + "plugins": [ + "react" + ], + "rules": { + "max-len": 0, + "no-invalid-this": 0, + "no-unused-vars": 0, + "require-jsdoc": 0 + } +} \ No newline at end of file diff --git a/packages/metal-jsx/test/.eslintrc.json b/packages/metal-jsx/test/.eslintrc.json deleted file mode 100644 index 92b466f1..00000000 --- a/packages/metal-jsx/test/.eslintrc.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "env": { - "mocha": true - }, - "globals": { - "assert": true, - "sinon": true - } -} diff --git a/packages/metal-jsx/test/DangerouslySetHTML.js b/packages/metal-jsx/test/DangerouslySetHTML.js index 64d78f7e..755f8b76 100644 --- a/packages/metal-jsx/test/DangerouslySetHTML.js +++ b/packages/metal-jsx/test/DangerouslySetHTML.js @@ -4,7 +4,7 @@ import DangerouslySetHTML from '../src/DangerouslySetHTML'; import JSXComponent from '../src/JSXComponent'; describe('JSXComponent', function() { - var component; + let component; afterEach(function() { if (component) { @@ -23,14 +23,14 @@ describe('JSXComponent', function() { }); it('should render with html content', function() { - var content = '

hello

world
'; + let content = '

hello

world
'; component = new DangerouslySetHTML({content: content}); assert.strictEqual(content, component.element.innerHTML); }); it('should render inside of another component', function() { - var content = '

hello

world
'; + let content = '

hello

world
'; class TestComponent extends JSXComponent { render() { diff --git a/packages/metal-jsx/test/JSXComponent.js b/packages/metal-jsx/test/JSXComponent.js index 26ede454..fce3e10f 100644 --- a/packages/metal-jsx/test/JSXComponent.js +++ b/packages/metal-jsx/test/JSXComponent.js @@ -1,11 +1,11 @@ 'use strict'; -import { async } from 'metal'; +import {async} from 'metal'; import dom from 'metal-dom'; import JSXComponent from '../src/JSXComponent'; describe('JSXComponent', function() { - var component; + let component; afterEach(function() { if (component) { @@ -27,8 +27,7 @@ describe('JSXComponent', function() { }); it('should not throw error if no jsx function is implemented', function() { - class TestComponent extends JSXComponent { - } + class TestComponent extends JSXComponent {} component = new TestComponent(); assert.strictEqual('DIV', component.element.tagName); @@ -38,9 +37,11 @@ describe('JSXComponent', function() { it('should attach inline listeners', function() { class TestComponent extends JSXComponent { render() { - return
- -
; + return ( +
+
+ ); } } TestComponent.prototype.handleClick = sinon.stub(); @@ -59,14 +60,16 @@ describe('JSXComponent', function() { class TestComponent extends JSXComponent { render() { - return
- -
; + return ( +
+ +
+ ); } } component = new TestComponent(); - var child = component.components.child; + let child = component.components.child; assert.ok(child); assert.strictEqual('DIV', child.element.tagName); assert.ok(dom.hasClass(child.element, 'child')); @@ -83,14 +86,16 @@ describe('JSXComponent', function() { class TestComponent extends JSXComponent { render() { - return
- -
; + return ( +
+ +
+ ); } } component = new TestComponent(); - var child = component.components.child; + let child = component.components.child; assert.strictEqual('Foo', child.element.textContent); }); @@ -131,9 +136,7 @@ describe('JSXComponent', function() { it('should be able to render only some of the received children', function() { class ChildComponent extends JSXComponent { render() { - return
- {this.props.children[1]} -
; + return
{this.props.children[1]}
; } } @@ -147,12 +150,12 @@ describe('JSXComponent', function() { Children Test 3
- ); + ); } } component = new TestComponent(); - var child = component.components.child; + let child = component.components.child; assert.strictEqual(1, child.element.childNodes.length); assert.strictEqual('SPAN', child.element.childNodes[0].tagName); assert.strictEqual('Children Test 2', child.element.textContent); @@ -161,10 +164,12 @@ describe('JSXComponent', function() { it('should be able to get the data passed to children', function() { class ChildComponent extends JSXComponent { render() { - return
- {this.props.children[0].config.foo} - {this.props.children} -
; + return ( +
+ {this.props.children[0].config.foo} + {this.props.children} +
+ ); } } @@ -176,16 +181,19 @@ describe('JSXComponent', function() { Children Test
- ); + ); } } component = new TestComponent(); - var child = component.components.child; + let child = component.components.child; assert.strictEqual(2, child.element.childNodes.length); assert.strictEqual('foo', child.element.childNodes[0].textContent); assert.strictEqual('SPAN', child.element.childNodes[1].tagName); - assert.strictEqual('Children Test', child.element.childNodes[1].textContent); + assert.strictEqual( + 'Children Test', + child.element.childNodes[1].textContent + ); }); }); @@ -197,11 +205,11 @@ describe('JSXComponent', function() { } } - var container = document.createElement('div'); + let container = document.createElement('div'); component = JSXComponent.render( TestComponent, { - foo: 'fooValue' + foo: 'fooValue', }, container ); @@ -215,14 +223,14 @@ describe('JSXComponent', function() { }); it('should render componentless functions via "JSXComponent.render"', function() { - var fn = props => { + let fn = props => { return
{props.foo}
; }; - var container = document.createElement('div'); + let container = document.createElement('div'); JSXComponent.render( fn, { - foo: 'fooValue' + foo: 'fooValue', }, container ); @@ -234,11 +242,8 @@ describe('JSXComponent', function() { }); it('should render jsx element via "JSXComponent.render"', function() { - var container = document.createElement('div'); - JSXComponent.render( -
foo
, - container - ); + let container = document.createElement('div'); + JSXComponent.render(
foo
, container); assert.strictEqual(1, container.childNodes.length); assert.strictEqual('DIV', container.childNodes[0].tagName); @@ -249,12 +254,11 @@ describe('JSXComponent', function() { describe('STATE and PROPS', function() { it('should allow specifying configuration for props', function() { - class TestComponent extends JSXComponent { - } + class TestComponent extends JSXComponent {} TestComponent.PROPS = { foo: { - value: 'defaultFoo' - } + value: 'defaultFoo', + }, }; component = new TestComponent(); @@ -262,12 +266,11 @@ describe('JSXComponent', function() { }); it('should allow specifying internal state', function() { - class TestComponent extends JSXComponent { - } + class TestComponent extends JSXComponent {} TestComponent.STATE = { foo: { - value: 'defaultFoo' - } + value: 'defaultFoo', + }, }; component = new TestComponent(); @@ -289,26 +292,28 @@ describe('JSXComponent', function() { } TestComponent.STATE = { foo: { - value: 'foo' - } + value: 'foo', + }, }; component = new TestComponent(); - var child = component.components.child; + let child = component.components.child; component.state.foo = 'foo2'; component.once('rendered', function() { assert.strictEqual('foo2', child.element.textContent); assert.strictEqual(1, child.propsChanged.callCount); - var prevProps = child.propsChanged.args[0][0]; + let prevProps = child.propsChanged.args[0][0]; assert.strictEqual('foo', prevProps.foo); assert.strictEqual('foo2', child.props.foo); done(); }); }); - it('should allow changes to state in "willReceiveProps" without triggering multiple renders', function(done) { + it('should allow changes to state in "willReceiveProps" without triggering multiple renders', function( + done + ) { const renderStub = sinon.stub(); let count = 0; @@ -316,7 +321,11 @@ describe('JSXComponent', function() { render() { renderStub(); - return
{this.props.bar}:{this.state.foo}
; + return ( +
+ {this.props.bar}:{this.state.foo} +
+ ); } willReceiveProps(data) { @@ -327,13 +336,13 @@ describe('JSXComponent', function() { } TestComponent.STATE = { foo: { - value: 'foo' - } + value: 'foo', + }, }; TestComponent.PROPS = { bar: { - value: 'bar' - } + value: 'bar', + }, }; component = new TestComponent(); @@ -355,14 +364,15 @@ describe('JSXComponent', function() { }); }); - it('should pass changed props data to "willReceiveProps" method', function(done) { - class TestComponent extends JSXComponent { - } + it('should pass changed props data to "willReceiveProps" method', function( + done + ) { + class TestComponent extends JSXComponent {} TestComponent.prototype.willReceiveProps = sinon.stub(); TestComponent.PROPS = { foo: { - value: 'foo' - } + value: 'foo', + }, }; component = new TestComponent(); @@ -375,8 +385,8 @@ describe('JSXComponent', function() { foo: { key: 'foo', newVal: 'foo2', - prevVal: 'foo' - } + prevVal: 'foo', + }, }); done(); @@ -386,7 +396,7 @@ describe('JSXComponent', function() { it('component.element and child.element should be the same', function() { class ChildComponent extends JSXComponent { render() { - return
; + return
; } } @@ -397,14 +407,14 @@ describe('JSXComponent', function() { } component = new ParentComponent(); - var child = component.refs.child; + let child = component.refs.child; assert.strictEqual(component.element, child.element); }); it('should receive elementClasses from parent component', function() { class ChildComponent extends JSXComponent { render() { - return
; + return
; } } @@ -422,7 +432,7 @@ describe('JSXComponent', function() { it('should not apply undefined class', function() { class ChildComponent extends JSXComponent { render() { - return
; + return
; } } @@ -439,7 +449,7 @@ describe('JSXComponent', function() { it('should not create duplicate classes', function() { class ChildComponent extends JSXComponent { render() { - return
; + return
; } } @@ -456,7 +466,7 @@ describe('JSXComponent', function() { it('should pass elementClasses through higher order components', function() { class GrandChildComponent extends JSXComponent { render() { - return
; + return
; } } @@ -480,7 +490,9 @@ describe('JSXComponent', function() { }); describe('shouldUpdate', function() { - it('should not rerender after props change if shouldUpdate returns false', function(done) { + it('should not rerender after props change if shouldUpdate returns false', function( + done + ) { class TestComponent extends JSXComponent { render() {} @@ -490,8 +502,8 @@ describe('JSXComponent', function() { } TestComponent.PROPS = { foo: { - value: 'defaultFoo' - } + value: 'defaultFoo', + }, }; component = new TestComponent(); @@ -503,7 +515,9 @@ describe('JSXComponent', function() { }); }); - it('should not rerender after state change if shouldUpdate returns false', function(done) { + it('should not rerender after state change if shouldUpdate returns false', function( + done + ) { class TestComponent extends JSXComponent { render() {} @@ -513,8 +527,8 @@ describe('JSXComponent', function() { } TestComponent.STATE = { foo: { - value: 'defaultFoo' - } + value: 'defaultFoo', + }, }; component = new TestComponent(); @@ -528,7 +542,9 @@ describe('JSXComponent', function() { }); describe('SYNC_UPDATES', function() { - it('should update parent component with SYNC_UPDATES during child render', function(done) { + it('should update parent component with SYNC_UPDATES during child render', function( + done + ) { class ChildComponent extends JSXComponent { attached() { this.props.updateFoo('Child'); @@ -541,18 +557,23 @@ describe('JSXComponent', function() { class TestComponent extends JSXComponent { render() { - return
- {this.state.foo} - {this.state.show ? this.state.foo += newFoo} /> : null} -
; + return ( +
+ {this.state.foo} + {this.state.show ? ( + (this.state.foo += newFoo)} + /> + ) : null} +
+ ); } } TestComponent.STATE = { foo: { - value: 'foo' + value: 'foo', }, - show: { - } + show: {}, }; TestComponent.SYNC_UPDATES = true; @@ -566,7 +587,9 @@ describe('JSXComponent', function() { }); }); - it('should update parent component with SYNC_UPDATES during root child render', function(done) { + it('should update parent component with SYNC_UPDATES during root child render', function( + done + ) { class ChildComponent extends JSXComponent { attached() { this.props.updateFoo('Child'); @@ -579,17 +602,19 @@ describe('JSXComponent', function() { class TestComponent extends JSXComponent { render() { - return this.state.show ? - this.state.foo += newFoo} /> : - null; + return this.state.show ? ( + (this.state.foo += newFoo)} + /> + ) : null; } } TestComponent.STATE = { foo: { - value: 'foo' + value: 'foo', }, - show: { - } + show: {}, }; TestComponent.SYNC_UPDATES = true; @@ -604,7 +629,7 @@ describe('JSXComponent', function() { }); describe('otherProps', function() { - var component; + let component; afterEach(function() { if (component) { @@ -637,10 +662,7 @@ describe('JSXComponent', function() { component = new TestComponent({baz: 'qux', foo: 'bar'}); - assert.deepEqual( - component.otherProps(), - {baz: 'qux'} - ); + assert.deepEqual(component.otherProps(), {baz: 'qux'}); }); it('should ignore key and ref', function() { @@ -652,10 +674,7 @@ describe('JSXComponent', function() { component = new TestComponent({key: 'bar', ref: 'qux'}); - assert.deepEqual( - component.otherProps(), - {} - ); + assert.deepEqual(component.otherProps(), {}); }); }); }); diff --git a/packages/metal-jsx/test/JSXDataManager.js b/packages/metal-jsx/test/JSXDataManager.js index d2b2465d..9b3fd9fc 100644 --- a/packages/metal-jsx/test/JSXDataManager.js +++ b/packages/metal-jsx/test/JSXDataManager.js @@ -5,8 +5,8 @@ import IncrementalDomRenderer from 'metal-incremental-dom'; import JSXDataManager from '../src/JSXDataManager'; describe('JSXDataManager', function() { - var component; - var component2; + let component; + let component2; afterEach(function() { if (component) { @@ -18,8 +18,7 @@ describe('JSXDataManager', function() { }); it('should create "props" and "state" objects in component', function() { - class TestComponent extends Component { - } + class TestComponent extends Component {} TestComponent.DATA_MANAGER = JSXDataManager; component = new TestComponent(); @@ -29,13 +28,12 @@ describe('JSXDataManager', function() { describe('state', function() { it('should add properties from STATE to `state` variable', function() { - class TestComponent extends Component { - } + class TestComponent extends Component {} TestComponent.DATA_MANAGER = JSXDataManager; TestComponent.STATE = { foo: { - value: 'defaultFoo' - } + value: 'defaultFoo', + }, }; component = new TestComponent(); @@ -46,24 +44,22 @@ describe('JSXDataManager', function() { }); it('should not use constructor values for properties in STATE', function() { - class TestComponent extends Component { - } + class TestComponent extends Component {} TestComponent.DATA_MANAGER = JSXDataManager; TestComponent.STATE = { foo: { - value: 'defaultFoo' - } + value: 'defaultFoo', + }, }; component = new TestComponent({ - foo: 'foo' + foo: 'foo', }); assert.strictEqual('defaultFoo', component.state.foo); }); it('should not include default component data in "state"', function() { - class TestComponent extends Component { - } + class TestComponent extends Component {} TestComponent.DATA_MANAGER = JSXDataManager; component = new TestComponent(); @@ -73,13 +69,12 @@ describe('JSXDataManager', function() { }); it('should keep state objects different between component instances', function() { - class TestComponent extends Component { - } + class TestComponent extends Component {} TestComponent.DATA_MANAGER = JSXDataManager; TestComponent.STATE = { foo: { - value: 'defaultFoo' - } + value: 'defaultFoo', + }, }; component = new TestComponent(); @@ -95,7 +90,9 @@ describe('JSXDataManager', function() { assert.equal('foo2', component2.state.foo); }); - it('should run setState\'s callback after component is rerendered', function(done) { + it('should run setState\'s callback after component is rerendered', function( + done + ) { class TestComponent extends Component { render() {} } @@ -103,22 +100,25 @@ describe('JSXDataManager', function() { TestComponent.RENDERER = IncrementalDomRenderer; TestComponent.STATE = { foo: { - value: 'defaultFoo' - } + value: 'defaultFoo', + }, }; component = new TestComponent(); sinon.spy(component, 'render'); - component.setState({ - foo: 'newFoo' - }, () => { - assert.strictEqual(1, component.render.callCount); - done(); - }); + component.setState( + { + foo: 'newFoo', + }, + () => { + assert.strictEqual(1, component.render.callCount); + done(); + } + ); }); - it('should now allow changes to a component\'s props cause changes to another\s', function() { + it('should now allow changes to a component\'s props cause changes to anothers', function() { class TestComponent extends Component { render() {} } @@ -136,13 +136,12 @@ describe('JSXDataManager', function() { describe('props', function() { it('should add properties from PROPS to `props` variable', function() { - class TestComponent extends Component { - } + class TestComponent extends Component {} TestComponent.DATA_MANAGER = JSXDataManager; TestComponent.PROPS = { foo: { - value: 'defaultFoo' - } + value: 'defaultFoo', + }, }; component = new TestComponent(); @@ -153,40 +152,37 @@ describe('JSXDataManager', function() { }); it('should use constructor values for properties in PROPS', function() { - class TestComponent extends Component { - } + class TestComponent extends Component {} TestComponent.DATA_MANAGER = JSXDataManager; TestComponent.PROPS = { foo: { - value: 'defaultFoo' - } + value: 'defaultFoo', + }, }; component = new TestComponent({ - foo: 'foo' + foo: 'foo', }); assert.strictEqual('foo', component.props.foo); }); it('should use default prop value when "undefined" is passed as initial value', function() { - class TestComponent extends Component { - } + class TestComponent extends Component {} TestComponent.DATA_MANAGER = JSXDataManager; TestComponent.PROPS = { foo: { - value: 'defaultFoo' - } + value: 'defaultFoo', + }, }; component = new TestComponent({ - foo: undefined + foo: undefined, }); assert.strictEqual('defaultFoo', component.props.foo); }); it('should include default component data in "props"', function() { - class TestComponent extends Component { - } + class TestComponent extends Component {} TestComponent.DATA_MANAGER = JSXDataManager; component = new TestComponent(); @@ -196,13 +192,12 @@ describe('JSXDataManager', function() { }); it('should keep prop objects different between component instances', function() { - class TestComponent extends Component { - } + class TestComponent extends Component {} TestComponent.DATA_MANAGER = JSXDataManager; TestComponent.PROPS = { foo: { - value: 'defaultFoo' - } + value: 'defaultFoo', + }, }; component = new TestComponent(); @@ -219,88 +214,84 @@ describe('JSXDataManager', function() { }); it('should return value from "props" when "get" is called', function() { - class TestComponent extends Component { - } + class TestComponent extends Component {} TestComponent.DATA_MANAGER = JSXDataManager; TestComponent.PROPS = { foo: { - value: 'defaultPropsFoo' - } + value: 'defaultPropsFoo', + }, }; TestComponent.STATE = { foo: { - value: 'defaultStateFoo' - } + value: 'defaultStateFoo', + }, }; component = new TestComponent(); assert.strictEqual('defaultPropsFoo', component.props.foo); assert.strictEqual('defaultStateFoo', component.state.foo); - var manager = component.getDataManager(); + let manager = component.getDataManager(); assert.strictEqual('defaultPropsFoo', manager.get(component, 'foo')); }); it('should return the "State" instance for props from "getPropsInstance"', function() { - class TestComponent extends Component { - } + class TestComponent extends Component {} TestComponent.DATA_MANAGER = JSXDataManager; TestComponent.PROPS = { foo: { - value: 'defaultPropsFoo' - } + value: 'defaultPropsFoo', + }, }; TestComponent.STATE = { foo: { - value: 'defaultStateFoo' - } + value: 'defaultStateFoo', + }, }; component = new TestComponent(); - var propsInstance = component.getDataManager().getPropsInstance(component); + let propsInstance = component + .getDataManager() + .getPropsInstance(component); assert.ok(propsInstance); assert.equal('defaultPropsFoo', propsInstance.get('foo')); }); it('should return keys from "props" when "getSyncKeys" is called', function() { - class TestComponent extends Component { - } + class TestComponent extends Component {} TestComponent.DATA_MANAGER = JSXDataManager; TestComponent.PROPS = { - foo: { - } + foo: {}, }; TestComponent.STATE = { - bar: { - } + bar: {}, }; component = new TestComponent(); - var manager = component.getDataManager(); - var expected = ['children', 'elementClasses', 'events', 'foo', 'visible']; + let manager = component.getDataManager(); + let expected = ['children', 'elementClasses', 'events', 'foo', 'visible']; assert.deepEqual(expected, manager.getSyncKeys(component).sort()); }); }); describe('replaceNonInternal', function() { it('should replace props with given values', function() { - class TestComponent extends Component { - } + class TestComponent extends Component {} TestComponent.DATA_MANAGER = JSXDataManager; TestComponent.PROPS = { bar: { - value: 'defaultBar' + value: 'defaultBar', }, foo: { - value: 'defaultFoo' - } + value: 'defaultFoo', + }, }; component = new TestComponent(); - var manager = component.getDataManager(); + let manager = component.getDataManager(); manager.replaceNonInternal(component, { bar: 'bar', - foo: 'foo' + foo: 'foo', }); assert.strictEqual('bar', component.props.bar); @@ -308,22 +299,21 @@ describe('JSXDataManager', function() { }); it('should replace props with default values if no value is given', function() { - class TestComponent extends Component { - } + class TestComponent extends Component {} TestComponent.DATA_MANAGER = JSXDataManager; TestComponent.PROPS = { bar: { - value: 'defaultBar' + value: 'defaultBar', }, foo: { - value: 'defaultFoo' - } + value: 'defaultFoo', + }, }; component = new TestComponent(); - var manager = component.getDataManager(); + let manager = component.getDataManager(); manager.replaceNonInternal(component, { - bar: 'bar' + bar: 'bar', }); assert.strictEqual('bar', component.props.bar); @@ -331,38 +321,36 @@ describe('JSXDataManager', function() { }); it('should not replace state values', function() { - class TestComponent extends Component { - } + class TestComponent extends Component {} TestComponent.DATA_MANAGER = JSXDataManager; TestComponent.STATE = { foo: { - value: 'defaultFoo' - } + value: 'defaultFoo', + }, }; component = new TestComponent(); - var manager = component.getDataManager(); + let manager = component.getDataManager(); manager.replaceNonInternal(component, { - foo: 'foo' + foo: 'foo', }); assert.strictEqual('defaultFoo', component.state.foo); }); it('should manually set prop values not specified in PROPS', function() { - class TestComponent extends Component { - } + class TestComponent extends Component {} TestComponent.DATA_MANAGER = JSXDataManager; TestComponent.PROPS = { bar: { - value: 'defaultBar' - } + value: 'defaultBar', + }, }; component = new TestComponent(); - var manager = component.getDataManager(); + let manager = component.getDataManager(); manager.replaceNonInternal(component, { bar: 'bar', - foo: 'foo' + foo: 'foo', }); assert.strictEqual('bar', component.props.bar); @@ -370,20 +358,19 @@ describe('JSXDataManager', function() { }); it('should call "propsChanged" lifecycle method when props are replaced', function() { - class TestComponent extends Component { - } + class TestComponent extends Component {} TestComponent.prototype.propsChanged = sinon.stub(); TestComponent.DATA_MANAGER = JSXDataManager; TestComponent.PROPS = { foo: { - value: 'defaultFoo' - } + value: 'defaultFoo', + }, }; component = new TestComponent(); - var manager = component.getDataManager(); + let manager = component.getDataManager(); manager.replaceNonInternal(component, { - foo: 'foo' + foo: 'foo', }); assert.strictEqual(1, component.propsChanged.callCount); diff --git a/packages/metal-jsx/test/JSXRenderer.js b/packages/metal-jsx/test/JSXRenderer.js index b69dc9e3..a36f44a6 100644 --- a/packages/metal-jsx/test/JSXRenderer.js +++ b/packages/metal-jsx/test/JSXRenderer.js @@ -31,7 +31,7 @@ describe('JSXRenderer', function() { it('should render returned contents from variable in "render" function', function() { class TestComponent extends TestJSXComponent { render() { - var jsx =
Hello World
; + let jsx =
Hello World
; return jsx; } } @@ -59,18 +59,20 @@ describe('JSXRenderer', function() { Children Test 3
- ); + ); } } component = new TestComponent(); - var child = component.components.child; + let child = component.components.child; assert.strictEqual('SPAN', child.element.tagName); assert.strictEqual(1, child.element.childNodes.length); assert.strictEqual('Children Test 2', child.element.textContent); }); - it('should reuse child empty component when it renders content for the first time', function(done) { + it('should reuse child empty component when it renders content for the first time', function( + done + ) { class Wrapper extends TestJSXComponent { render() { return this.props.children; @@ -88,24 +90,25 @@ describe('JSXRenderer', function() { } } Child.STATE = { - show: { - } + show: {}, }; class TestComponent extends TestJSXComponent { render() { - return -
- -
-
; + return ( + +
+ +
+
+ ); } } const element = document.createElement('div'); dom.enterDocument(element); component = new TestComponent({ - element + element, }); assert.strictEqual(1, childInstances.length); const child = childInstances[0]; @@ -120,7 +123,9 @@ describe('JSXRenderer', function() { }); }); - it('should reuse child empty component when its parent makes it render content for the first time', function(done) { + it('should reuse child empty component when its parent makes it render content for the first time', function( + done + ) { class Wrapper extends TestJSXComponent { render() { return this.props.children; @@ -140,22 +145,23 @@ describe('JSXRenderer', function() { class TestComponent extends TestJSXComponent { render() { - return -
- -
-
; + return ( + +
+ +
+
+ ); } } TestComponent.STATE = { - show: { - } + show: {}, }; const element = document.createElement('div'); dom.enterDocument(element); component = new TestComponent({ - element + element, }); assert.strictEqual(1, childInstances.length); const child = childInstances[0]; @@ -178,8 +184,8 @@ describe('JSXRenderer', function() { } TestComponent.PROPS = { foo: { - value: 'defaultFoo' - } + value: 'defaultFoo', + }, }; component = new TestComponent(); @@ -200,8 +206,8 @@ describe('JSXRenderer', function() { } TestComponent.STATE = { foo: { - value: 'defaultFoo' - } + value: 'defaultFoo', + }, }; component = new TestComponent(); @@ -219,12 +225,10 @@ describe('JSXRenderer', function() { shouldUpdate() {} } TestComponent.PROPS = { - bar: { - } + bar: {}, }; TestComponent.STATE = { - foo: { - } + foo: {}, }; component = new TestComponent(); @@ -253,12 +257,10 @@ describe('JSXRenderer', function() { willUpdate() {} } TestComponent.PROPS = { - bar: { - } + bar: {}, }; TestComponent.STATE = { - foo: { - } + foo: {}, }; component = new TestComponent(); @@ -295,19 +297,20 @@ describe('JSXRenderer', function() { class TestComponent extends TestJSXComponent { render() { - return
- - {this.state.foo} -
; + return ( +
+ + {this.state.foo} +
+ ); } } TestComponent.STATE = { - foo: { - } + foo: {}, }; component = new TestComponent(); - var childNodes = component.element.childNodes; + let childNodes = component.element.childNodes; assert.equal(2, childNodes.length); component.state.foo = 'foo'; @@ -320,32 +323,44 @@ describe('JSXRenderer', function() { }); }); - it('should reuse component rendered after a conditionally rendered component', function(done) { + it('should reuse component rendered after a conditionally rendered component', function( + done + ) { class ChildComponent extends TestJSXComponent { render() { return Child; } } - class ChildComponent2 extends ChildComponent { - } + class ChildComponent2 extends ChildComponent {} class TestComponent extends TestJSXComponent { render() { - return
- {!this.props.hide &&
} -
-
; + return ( +
+ {!this.props.hide && ( +
+ +
+ )} +
+ +
+
+ ); } } TestComponent.PROPS = { - hide: { - } + hide: {}, }; class ParentComponent extends TestJSXComponent { render() { - return
; + return ( +
+ +
+ ); } } @@ -374,15 +389,16 @@ describe('JSXRenderer', function() { it('should reuse elements with keys after moving around', function(done) { class TestComponent extends TestJSXComponent { render() { - return
- - -
; + return ( +
+ + +
+ ); } } TestComponent.PROPS = { - switch: { - } + switch: {}, }; component = new TestComponent(); @@ -410,15 +426,16 @@ describe('JSXRenderer', function() { class TestComponent extends TestJSXComponent { render() { - return
- - -
; + return ( +
+ + +
+ ); } } TestComponent.PROPS = { - switch: { - } + switch: {}, }; component = new TestComponent(); @@ -447,16 +464,18 @@ describe('JSXRenderer', function() { } ChildComponent.PROPS = { foo: { - value: 'initialFoo' - } + value: 'initialFoo', + }, }; class TestComponent extends TestJSXComponent { render() { - return
-
Test
- -
; + return ( +
+
Test
+ +
+ ); } } @@ -473,13 +492,17 @@ describe('JSXRenderer', function() { it('should reuse elements correctly after a child update', function(done) { class ChildComponent extends TestJSXComponent { render() { - return
{this.props.foo}
; + return ( +
+ {this.props.foo} +
+ ); } } ChildComponent.PROPS = { foo: { - value: 'initialFoo' - } + value: 'initialFoo', + }, }; class TestComponent extends TestJSXComponent { @@ -490,7 +513,7 @@ describe('JSXRenderer', function() { component = new TestComponent(); const child = component.refs.child; - var spanEl = child.element.childNodes[0]; + let spanEl = child.element.childNodes[0]; component.refs.child.props.foo = 'newFoo'; component.refs.child.once('stateSynced', function() { @@ -499,7 +522,9 @@ describe('JSXRenderer', function() { }); }); - it('should reuse elements correctly after update from previously empty child', function(done) { + it('should reuse elements correctly after update from previously empty child', function( + done + ) { let child; class ChildComponent extends TestJSXComponent { created() { @@ -512,16 +537,18 @@ describe('JSXRenderer', function() { } ChildComponent.STATE = { first: { - value: true - } + value: true, + }, }; class TestComponent extends TestJSXComponent { render() { - return
-
First child element
- -
; + return ( +
+
First child element
+ +
+ ); } } diff --git a/packages/metal-soy-bundle/package-lock.json b/packages/metal-soy-bundle/package-lock.json index 37f00daa..3fe583ac 100644 --- a/packages/metal-soy-bundle/package-lock.json +++ b/packages/metal-soy-bundle/package-lock.json @@ -107,7 +107,7 @@ "lodash": "4.17.4", "minimatch": "3.0.4", "path-is-absolute": "1.0.1", - "private": "0.1.7", + "private": "0.1.8", "slash": "1.0.0", "source-map": "0.5.7" } @@ -550,9 +550,9 @@ } }, "babel-preset-env": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/babel-preset-env/-/babel-preset-env-1.6.0.tgz", - "integrity": "sha512-OVgtQRuOZKckrILgMA5rvctvFZPv72Gua9Rt006AiPoB0DJKGN07UmaQA+qRrYgK71MVct8fFhT0EyNWYorVew==", + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/babel-preset-env/-/babel-preset-env-1.6.1.tgz", + "integrity": "sha512-W6VIyA6Ch9ePMI7VptNn2wBM6dbG0eSz25HEiL40nQXCsXGTGZSTZu1Iap+cj3Q0S5a7T9+529l/5Bkvd+afNA==", "requires": { "babel-plugin-check-es2015-constants": "6.22.0", "babel-plugin-syntax-trailing-function-commas": "6.22.0", @@ -581,7 +581,7 @@ "babel-plugin-transform-es2015-unicode-regex": "6.24.1", "babel-plugin-transform-exponentiation-operator": "6.24.1", "babel-plugin-transform-regenerator": "6.26.0", - "browserslist": "2.5.1", + "browserslist": "2.8.0", "invariant": "2.2.2", "semver": "5.4.1" } @@ -688,18 +688,18 @@ } }, "browserslist": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-2.5.1.tgz", - "integrity": "sha512-jAvM2ku7YDJ+leAq3bFH1DE0Ylw+F+EQDq4GkqZfgPEqpWYw9ofQH85uKSB9r3Tv7XDbfqVtE+sdvKJW7IlPJA==", + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-2.8.0.tgz", + "integrity": "sha512-iiWHM1Et6Q4TQpB7Ar6pxuM3TNMXasVJY4Y/oh3q38EwR3Z+IdZ9MyVf7PI4MJFB4xpwMcZgs9bEUnPG2E3TCA==", "requires": { - "caniuse-lite": "1.0.30000746", - "electron-to-chromium": "1.3.25" + "caniuse-lite": "1.0.30000760", + "electron-to-chromium": "1.3.27" } }, "caniuse-lite": { - "version": "1.0.30000746", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000746.tgz", - "integrity": "sha1-xk+Vo5Jc/TAgejCO12wa6W6gnqA=" + "version": "1.0.30000760", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000760.tgz", + "integrity": "sha1-7HIDlXQvHH7IlH/W3SYE53qPmP8=" }, "chalk": { "version": "1.1.3", @@ -723,9 +723,9 @@ } }, "clone": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.2.tgz", - "integrity": "sha1-Jgt6meux7f4kdTgXX3gyQ8sZ0Uk=" + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.3.tgz", + "integrity": "sha1-KY1+IjFmD0DAA8LtMUDezz9TCF8=" }, "clone-buffer": { "version": "1.0.0", @@ -811,7 +811,7 @@ "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.3.tgz", "integrity": "sha1-xlYFHpgX2f8I7YgUd/P+QBnz730=", "requires": { - "clone": "1.0.2" + "clone": "1.0.3" } }, "deprecated": { @@ -892,9 +892,9 @@ } }, "electron-to-chromium": { - "version": "1.3.25", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.25.tgz", - "integrity": "sha1-RTshAJg20Jl9hgNWAf9srkeRxGA=" + "version": "1.3.27", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.27.tgz", + "integrity": "sha1-eOy4o5kGYYe7N07t412ccFZagD0=" }, "end-of-stream": { "version": "0.1.5", @@ -1548,9 +1548,9 @@ } }, "is-buffer": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.5.tgz", - "integrity": "sha1-Hzsm72E7IUuIy8ojzGwB2Hlh7sw=" + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==" }, "is-dotfile": { "version": "1.0.3", @@ -1726,7 +1726,7 @@ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "requires": { - "is-buffer": "1.1.5" + "is-buffer": "1.1.6" } }, "liftoff": { @@ -1742,7 +1742,7 @@ "lodash.isstring": "4.0.1", "lodash.mapvalues": "4.6.0", "rechoir": "0.6.2", - "resolve": "1.4.0" + "resolve": "1.5.0" } }, "lodash": { @@ -2134,9 +2134,9 @@ "integrity": "sha1-t+PqQkNaTJsnWdmeDyAesZWALuE=" }, "private": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/private/-/private-0.1.7.tgz", - "integrity": "sha1-aM5eih7woju1cMwoU3tTMqumPvE=" + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/private/-/private-0.1.8.tgz", + "integrity": "sha512-VvivMrbvd2nKkiG38qjULzlc+4Vx4wm/whI9pQD35YrARNnhxeiRktSOhSukRLFNlzg6Br/cJPet5J/u19r/mg==" }, "process-nextick-args": { "version": "1.0.7", @@ -2165,7 +2165,7 @@ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "requires": { - "is-buffer": "1.1.5" + "is-buffer": "1.1.6" } } } @@ -2175,7 +2175,7 @@ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", "requires": { - "is-buffer": "1.1.5" + "is-buffer": "1.1.6" } } } @@ -2196,7 +2196,7 @@ "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz", "integrity": "sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=", "requires": { - "resolve": "1.4.0" + "resolve": "1.5.0" } }, "regenerate": { @@ -2216,7 +2216,7 @@ "requires": { "babel-runtime": "6.26.0", "babel-types": "6.26.0", - "private": "0.1.7" + "private": "0.1.8" } }, "regex-cache": { @@ -2325,9 +2325,9 @@ } }, "resolve": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.4.0.tgz", - "integrity": "sha512-aW7sVKPufyHqOmyyLzg/J+8606v5nevBgaliIlV7nUpVMsDnoBGV/cbSLNjZAg9q0Cfd/+easKVKQ8vOu8fn1Q==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.5.0.tgz", + "integrity": "sha512-hgoSGrc3pjzAPHNBg+KnFcK2HwlHTs/YrAGUr6qgTVUZmXv1UEXXl0bZNBKMA9fud6lRYFdPGz0xXxycPzmmiw==", "requires": { "path-parse": "1.0.5" } @@ -2546,7 +2546,7 @@ "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-0.5.3.tgz", "integrity": "sha1-sEVbOPxeDPMNQyUTLkYZcMIJHN4=", "requires": { - "clone": "1.0.2", + "clone": "1.0.3", "clone-stats": "0.0.1", "replace-ext": "0.0.1" } diff --git a/packages/metal-incremental-dom/.eslintrc.json b/packages/metal-soy/.eslintrc similarity index 71% rename from packages/metal-incremental-dom/.eslintrc.json rename to packages/metal-soy/.eslintrc index 6b06731d..4376a325 100644 --- a/packages/metal-incremental-dom/.eslintrc.json +++ b/packages/metal-soy/.eslintrc @@ -1,5 +1,6 @@ { "globals": { + "goog": true, "IncrementalDOM": true } -} +} \ No newline at end of file diff --git a/packages/metal-soy/.eslintrc.json b/packages/metal-soy/.eslintrc.json deleted file mode 100644 index bea5b805..00000000 --- a/packages/metal-soy/.eslintrc.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "globals": { - "goog": true, - "IncrementalDOM": true, - "soy": true, - "soydata": true - } -} diff --git a/packages/metal-soy/package-lock.json b/packages/metal-soy/package-lock.json index f9c637f5..7e4c66d6 100644 --- a/packages/metal-soy/package-lock.json +++ b/packages/metal-soy/package-lock.json @@ -64,7 +64,7 @@ "lodash": "4.17.4", "minimatch": "3.0.4", "path-is-absolute": "1.0.1", - "private": "0.1.7", + "private": "0.1.8", "slash": "1.0.0", "source-map": "0.5.7" } @@ -507,9 +507,9 @@ } }, "babel-preset-env": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/babel-preset-env/-/babel-preset-env-1.6.0.tgz", - "integrity": "sha512-OVgtQRuOZKckrILgMA5rvctvFZPv72Gua9Rt006AiPoB0DJKGN07UmaQA+qRrYgK71MVct8fFhT0EyNWYorVew==", + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/babel-preset-env/-/babel-preset-env-1.6.1.tgz", + "integrity": "sha512-W6VIyA6Ch9ePMI7VptNn2wBM6dbG0eSz25HEiL40nQXCsXGTGZSTZu1Iap+cj3Q0S5a7T9+529l/5Bkvd+afNA==", "requires": { "babel-plugin-check-es2015-constants": "6.22.0", "babel-plugin-syntax-trailing-function-commas": "6.22.0", @@ -538,7 +538,7 @@ "babel-plugin-transform-es2015-unicode-regex": "6.24.1", "babel-plugin-transform-exponentiation-operator": "6.24.1", "babel-plugin-transform-regenerator": "6.26.0", - "browserslist": "2.5.1", + "browserslist": "2.8.0", "invariant": "2.2.2", "semver": "5.4.1" } @@ -625,18 +625,18 @@ } }, "browserslist": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-2.5.1.tgz", - "integrity": "sha512-jAvM2ku7YDJ+leAq3bFH1DE0Ylw+F+EQDq4GkqZfgPEqpWYw9ofQH85uKSB9r3Tv7XDbfqVtE+sdvKJW7IlPJA==", + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-2.8.0.tgz", + "integrity": "sha512-iiWHM1Et6Q4TQpB7Ar6pxuM3TNMXasVJY4Y/oh3q38EwR3Z+IdZ9MyVf7PI4MJFB4xpwMcZgs9bEUnPG2E3TCA==", "requires": { - "caniuse-lite": "1.0.30000746", - "electron-to-chromium": "1.3.25" + "caniuse-lite": "1.0.30000760", + "electron-to-chromium": "1.3.27" } }, "caniuse-lite": { - "version": "1.0.30000746", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000746.tgz", - "integrity": "sha1-xk+Vo5Jc/TAgejCO12wa6W6gnqA=" + "version": "1.0.30000760", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000760.tgz", + "integrity": "sha1-7HIDlXQvHH7IlH/W3SYE53qPmP8=" }, "chalk": { "version": "1.1.3", @@ -687,9 +687,9 @@ } }, "electron-to-chromium": { - "version": "1.3.25", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.25.tgz", - "integrity": "sha1-RTshAJg20Jl9hgNWAf9srkeRxGA=" + "version": "1.3.27", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.27.tgz", + "integrity": "sha1-eOy4o5kGYYe7N07t412ccFZagD0=" }, "escape-string-regexp": { "version": "1.0.5", @@ -879,9 +879,9 @@ "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" }, "private": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/private/-/private-0.1.7.tgz", - "integrity": "sha1-aM5eih7woju1cMwoU3tTMqumPvE=" + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/private/-/private-0.1.8.tgz", + "integrity": "sha512-VvivMrbvd2nKkiG38qjULzlc+4Vx4wm/whI9pQD35YrARNnhxeiRktSOhSukRLFNlzg6Br/cJPet5J/u19r/mg==" }, "regenerate": { "version": "1.3.3", @@ -900,7 +900,7 @@ "requires": { "babel-runtime": "6.26.0", "babel-types": "6.26.0", - "private": "0.1.7" + "private": "0.1.8" } }, "regexpu-core": { diff --git a/packages/metal-soy/src/Soy.js b/packages/metal-soy/src/Soy.js index 9ab41d2e..866e9b63 100644 --- a/packages/metal-soy/src/Soy.js +++ b/packages/metal-soy/src/Soy.js @@ -1,15 +1,18 @@ 'use strict'; import 'metal-soy-bundle'; -import { ComponentRegistry } from 'metal-component'; -import { isFunction, isObject, isString, object } from 'metal'; -import { validators, Config } from 'metal-state'; -import IncrementalDomRenderer, { HTML2IncDom } from 'metal-incremental-dom'; +import {ComponentRegistry} from 'metal-component'; +import {isFunction, isObject, isString, object} from 'metal'; +import {validators, Config} from 'metal-state'; +import IncrementalDomRenderer, {HTML2IncDom} from 'metal-incremental-dom'; import SoyAop from './SoyAop'; // The injected data that will be passed to soy templates. let ijData = {}; +/** + * Soy Renderer + */ class Soy extends IncrementalDomRenderer.constructor { /** * Adds the template params to the component's state, if they don't exist yet. @@ -79,13 +82,17 @@ class Soy extends IncrementalDomRenderer.constructor { * @return {!function()} */ getTemplate(namespace, templateName) { - return function(opt_data, opt_ignored, opt_ijData) { + return function(data, ignored, ijData) { if (!goog.loadedModules_[namespace]) { throw new Error( `No template with namespace "${namespace}" has been loaded yet.` ); } - return goog.loadedModules_[namespace][templateName](opt_data, opt_ignored, opt_ijData); + return goog.loadedModules_[namespace][templateName]( + data, + ignored, + ijData + ); }; } @@ -98,10 +105,12 @@ class Soy extends IncrementalDomRenderer.constructor { * @param {Object} data The data the template was called with. * @protected */ - handleInterceptedCall_(originalFn, opt_data = {}) { + handleInterceptedCall_(originalFn, data = {}) { const args = [originalFn.componentCtor, null, []]; - for (let key in opt_data) { - args.push(key, opt_data[key]); + for (let key in data) { + if (Object.prototype.hasOwnProperty.call(data, key)) { + args.push(key, data[key]); + } } IncrementalDOM.elementVoid.apply(null, args); } @@ -111,6 +120,7 @@ class Soy extends IncrementalDomRenderer.constructor { * @param {!Component} component * @param {string} name * @protected + * @return {boolean} */ isHtmlParam_(component, name) { const state = component.getDataManager().getStateInstance(component); @@ -118,7 +128,9 @@ class Soy extends IncrementalDomRenderer.constructor { return true; } - const elementTemplate = SoyAop.getOriginalFn(component.constructor.TEMPLATE); + const elementTemplate = SoyAop.getOriginalFn( + component.constructor.TEMPLATE + ); const type = (elementTemplate.types || {})[name] || ''; return type.split('|').indexOf('html') !== -1; } @@ -152,7 +164,10 @@ class Soy extends IncrementalDomRenderer.constructor { if (isFunction(elementTemplate) && !component.render) { elementTemplate = SoyAop.getOriginalFn(elementTemplate); SoyAop.startInterception(this.handleInterceptedCall_); - const data = this.buildTemplateData_(component, elementTemplate.params || []); + const data = this.buildTemplateData_( + component, + elementTemplate.params || [] + ); elementTemplate(data, null, ijData); SoyAop.stopInterception(); } else { @@ -208,7 +223,11 @@ class Soy extends IncrementalDomRenderer.constructor { * @return {!function()} */ toIncDom(value) { - if (isObject(value) && isString(value.content) && (value.contentKind === 'HTML')) { + if ( + isObject(value) && + isString(value.content) && + value.contentKind === 'HTML' + ) { value = value.content; } if (isString(value)) { @@ -222,9 +241,4 @@ const soyRenderer_ = new Soy(); soyRenderer_.RENDERER_NAME = 'soy'; export default soyRenderer_; -export { - Config, - soyRenderer_ as Soy, - SoyAop, - validators -}; +export {Config, soyRenderer_ as Soy, SoyAop, validators}; diff --git a/packages/metal-soy/src/SoyAop.js b/packages/metal-soy/src/SoyAop.js index a59eb135..f3c516ec 100644 --- a/packages/metal-soy/src/SoyAop.js +++ b/packages/metal-soy/src/SoyAop.js @@ -25,18 +25,18 @@ const SoyAop = { * is set, or otherwise just calling the original function instead. * @param {!function()} originalFn The original template function that was * intercepted. - * @param {Object} opt_data Template data object. - * @param {*} opt_ignored - * @param {Object} opt_ijData Template injected data object. + * @param {Object=} data Template data object. + * @param {*=} ignored + * @param {Object=} ijData Template injected data object. * @return {*} The return value of the function that is called to handle this * interception. */ - handleTemplateCall_: function(originalFn, opt_data, opt_ignored, opt_ijData) { - const interceptFn = SoyAop.interceptFns_[SoyAop.interceptFns_.length - 1]; + handleTemplateCall_: function(originalFn, data, ignored, ijData) { + const interceptFn = SoyAop.interceptFns_[SoyAop.interceptFns_.length - 1]; // eslint-disable-line if (interceptFn) { - return interceptFn.call(null, originalFn, opt_data, opt_ignored, opt_ijData); + return interceptFn.call(null, originalFn, data, ignored, ijData); } else { - return originalFn.call(null, opt_data, opt_ignored, opt_ijData); + return originalFn.call(null, data, ignored, ijData); } }, @@ -75,7 +75,7 @@ const SoyAop = { */ stopInterception: function() { SoyAop.interceptFns_.pop(); - } + }, }; export default SoyAop; diff --git a/packages/metal-soy/test/.eslintrc b/packages/metal-soy/test/.eslintrc new file mode 100644 index 00000000..f6269b7a --- /dev/null +++ b/packages/metal-soy/test/.eslintrc @@ -0,0 +1,14 @@ +{ + "env": { + "mocha": true + }, + "globals": { + "assert": true, + "sinon": true + }, + "rules": { + "max-len": 0, + "no-invalid-this": 0, + "require-jsdoc": 0 + } +} \ No newline at end of file diff --git a/packages/metal-soy/test/.eslintrc.json b/packages/metal-soy/test/.eslintrc.json deleted file mode 100644 index 92b466f1..00000000 --- a/packages/metal-soy/test/.eslintrc.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "env": { - "mocha": true - }, - "globals": { - "assert": true, - "sinon": true - } -} diff --git a/packages/metal-soy/test/Soy.js b/packages/metal-soy/test/Soy.js index bdd49444..63d118e8 100644 --- a/packages/metal-soy/test/Soy.js +++ b/packages/metal-soy/test/Soy.js @@ -2,25 +2,28 @@ import dom from 'metal-dom'; import Component from 'metal-component'; -import { Events as EventsComponent } from './assets/Events.soy.js'; -import { ComputedData as ComputedDataComponent } from './assets/ComputedData.soy.js'; -import { ExternalTemplate as ExternalTemplateComponent } from './assets/ExternalTemplate.soy.js'; -import { Functions as FunctionsComponent } from './assets/Functions.soy.js'; -import { HelloWorld as HelloWorldComponent, templates as helloWorldTemplates } from './assets/HelloWorld.soy.js'; -import { HigherOrder as HigherOrderComponent } from './assets/HigherOrder.soy.js'; -import { HtmlContent as HtmlContentComponent } from './assets/HtmlContent.soy.js'; -import { IJData as IJDataComponent } from './assets/IJData.soy.js'; -import { Nested as NestedComponent } from './assets/Nested.soy.js'; -import { NestedDataAll as NestedDataAllComponent } from './assets/NestedDataAll.soy.js'; -import { NestedLevels as NestedLevelsComponent } from './assets/NestedLevels.soy.js'; -import { NestedMultiple as NestedMultipleComponent } from './assets/NestedMultiple.soy.js'; -import { NestedNoData as NestedNoDataComponent } from './assets/NestedNoData.soy.js'; -import { TemplateData as TemplateDataComponent } from './assets/TemplateData.soy.js'; +import {Events as EventsComponent} from './assets/Events.soy.js'; +import {ComputedData as ComputedDataComponent} from './assets/ComputedData.soy.js'; +import {ExternalTemplate as ExternalTemplateComponent} from './assets/ExternalTemplate.soy.js'; +import {Functions as FunctionsComponent} from './assets/Functions.soy.js'; +import { + HelloWorld as HelloWorldComponent, + templates as helloWorldTemplates, +} from './assets/HelloWorld.soy.js'; +import {HigherOrder as HigherOrderComponent} from './assets/HigherOrder.soy.js'; +import {HtmlContent as HtmlContentComponent} from './assets/HtmlContent.soy.js'; +import {IJData as IJDataComponent} from './assets/IJData.soy.js'; +import {Nested as NestedComponent} from './assets/Nested.soy.js'; +import {NestedDataAll as NestedDataAllComponent} from './assets/NestedDataAll.soy.js'; +import {NestedLevels as NestedLevelsComponent} from './assets/NestedLevels.soy.js'; +import {NestedMultiple as NestedMultipleComponent} from './assets/NestedMultiple.soy.js'; +import {NestedNoData as NestedNoDataComponent} from './assets/NestedNoData.soy.js'; +import {TemplateData as TemplateDataComponent} from './assets/TemplateData.soy.js'; import Soy from '../src/Soy'; describe('Soy', function() { - var comp; + let comp; afterEach(function() { if (comp) { @@ -38,14 +41,14 @@ describe('Soy', function() { it('should add soy param as state keys automatically', function() { comp = new HelloWorldComponent({ - name: 'Foo' + name: 'Foo', }); assert.strictEqual('Foo', comp.name); }); it('should pass state values to "render template"', function() { comp = new HelloWorldComponent({ - name: 'Foo' + name: 'Foo', }); assert.strictEqual('SPAN', comp.element.tagName); assert.strictEqual('Hello Foo!', comp.element.textContent); @@ -53,7 +56,7 @@ describe('Soy', function() { it('should update content when state values change', function(done) { comp = new HelloWorldComponent({ - name: 'Foo' + name: 'Foo', }); comp.name = 'Bar'; @@ -79,7 +82,9 @@ describe('Soy', function() { delete HelloWorldComponent.prototype.shouldUpdate; }); - it('should not trigger update when changed state key is not used by template', function(done) { + it('should not trigger update when changed state key is not used by template', function( + done + ) { comp = new HelloWorldComponent(); comp.visible = false; comp.once('stateSynced', function() { @@ -88,7 +93,9 @@ describe('Soy', function() { }); }); - it('should not trigger update when shouldUpdate returns false', function(done) { + it('should not trigger update when shouldUpdate returns false', function( + done + ) { HelloWorldComponent.prototype.shouldUpdate = function() { return false; }; @@ -101,7 +108,9 @@ describe('Soy', function() { }); }); - it('should trigger update when state key is not used by template if component shouldUpdate returns true', function(done) { + it('should trigger update when state key is not used by template if component shouldUpdate returns true', function( + done + ) { HelloWorldComponent.prototype.shouldUpdate = function() { return true; }; @@ -115,16 +124,21 @@ describe('Soy', function() { }); }); - it('should pass state values to "prepareStateForRender" and use them in the template', function(done) { + it('should pass state values to "prepareStateForRender" and use them in the template', function( + done + ) { ComputedDataComponent.prototype.shouldUpdate = function() { return true; }; ComputedDataComponent.prototype.prepareStateForRender = function(data) { - data.name = data.name.split('').reverse().join(''); + data.name = data.name + .split('') + .reverse() + .join(''); }; - comp = new ComputedDataComponent({ name: 'Foo' }); + comp = new ComputedDataComponent({name: 'Foo'}); assert.strictEqual('ooF', comp.element.textContent); @@ -139,21 +153,20 @@ describe('Soy', function() { it('should not add sub template soy params as state keys', function() { comp = new TemplateDataComponent({ - foo: 'foo' + foo: 'foo', }); assert.ok(!comp.foo); }); it('should pass non state config data to sub templates', function() { comp = new TemplateDataComponent({ - foo: 'foo' + foo: 'foo', }); assert.strictEqual('foo', comp.element.textContent); }); it('should not throw error if rendering component with no templates', function() { - class NoTemplateComponent extends Component { - } + class NoTemplateComponent extends Component {} NoTemplateComponent.RENDERER = Soy; assert.doesNotThrow(function() { @@ -161,12 +174,12 @@ describe('Soy', function() { }); }); - it('should not throw error if updating component with no templates', function(done) { - class NoTemplateComponent extends Component { - } + it('should not throw error if updating component with no templates', function( + done + ) { + class NoTemplateComponent extends Component {} NoTemplateComponent.STATE = { - foo: { - } + foo: {}, }; NoTemplateComponent.RENDERER = Soy; @@ -189,7 +202,7 @@ describe('Soy', function() { it('should allow specifying injected data content', function() { Soy.setInjectedData({ - content: 'Foo' + content: 'Foo', }); comp = new IJDataComponent(); assert.strictEqual('DIV', comp.element.tagName); @@ -204,8 +217,7 @@ describe('Soy', function() { }); it('should allow registering template with any name for a component', function() { - class TestComponent extends Component { - } + class TestComponent extends Component {} Soy.register(TestComponent, helloWorldTemplates, 'content'); comp = new TestComponent(); @@ -215,12 +227,10 @@ describe('Soy', function() { }); it('should use last component registration for the same template', function() { - class TestComponent extends Component { - } + class TestComponent extends Component {} Soy.register(TestComponent, helloWorldTemplates, 'content'); - class TestComponent2 extends Component { - } + class TestComponent2 extends Component {} Soy.register(TestComponent2, helloWorldTemplates, 'content'); assert.strictEqual(TestComponent.TEMPLATE, TestComponent2.TEMPLATE); @@ -240,42 +250,44 @@ describe('Soy', function() { }); it('should not throw error if soy template doesn\'t have params/types info', function() { - class TestComponent extends Component { - } - Soy.register( - TestComponent, - { - render: () => IncrementalDOM.elementVoid('div') - } - ); - assert.doesNotThrow(() => comp = new TestComponent()); + class TestComponent extends Component {} + Soy.register(TestComponent, { + render: () => IncrementalDOM.elementVoid('div'), + }); + assert.doesNotThrow(() => (comp = new TestComponent())); }); }); describe('HTML attributes', function() { it('should render html string attributes correctly', function() { comp = new HtmlContentComponent({ - content: 'HTML Content' + content: 'HTML Content', }); assert.strictEqual(1, comp.element.childNodes.length); assert.strictEqual('SPAN', comp.element.childNodes[0].tagName); assert.ok(dom.hasClass(comp.element.childNodes[0], 'custom')); - assert.strictEqual('HTML Content', comp.element.childNodes[0].textContent); + assert.strictEqual( + 'HTML Content', + comp.element.childNodes[0].textContent + ); }); it('should render html sanitized object attributes correctly', function() { comp = new HtmlContentComponent({ content: { content: 'HTML Content', - contentKind: 'HTML' - } + contentKind: 'HTML', + }, }); assert.strictEqual(1, comp.element.childNodes.length); assert.strictEqual('SPAN', comp.element.childNodes[0].tagName); assert.ok(dom.hasClass(comp.element.childNodes[0], 'custom')); - assert.strictEqual('HTML Content', comp.element.childNodes[0].textContent); + assert.strictEqual( + 'HTML Content', + comp.element.childNodes[0].textContent + ); }); }); @@ -306,7 +318,7 @@ describe('Soy', function() { }); it('should bind function listeners to component', function() { - var context; + let context; FunctionsComponent.prototype.handleClick = function() { context = this; }; @@ -326,7 +338,7 @@ describe('Soy', function() { it('should render and instantiate nested components', function() { comp = new NestedComponent(); - var nested = comp.components.hello; + let nested = comp.components.hello; assert.ok(nested instanceof HelloWorldComponent); assert.strictEqual(nested.element, comp.element.childNodes[0]); assert.strictEqual('Hello World!', nested.element.textContent); @@ -334,10 +346,10 @@ describe('Soy', function() { it('should pass data to nested components', function() { comp = new NestedComponent({ - name: 'Foo' + name: 'Foo', }); - var nested = comp.components.hello; + let nested = comp.components.hello; assert.ok(nested instanceof HelloWorldComponent); assert.strictEqual(nested.element, comp.element.childNodes[0]); assert.strictEqual('Hello Foo!', nested.element.textContent); @@ -345,10 +357,10 @@ describe('Soy', function() { it('should pass data via `data="all"` to nested components', function() { comp = new NestedDataAllComponent({ - name: 'Foo' + name: 'Foo', }); - var nested = comp.components.hello; + let nested = comp.components.hello; assert.ok(nested instanceof HelloWorldComponent); assert.strictEqual(nested.element, comp.element.childNodes[0]); assert.strictEqual('Hello Foo!', nested.element.textContent); @@ -357,19 +369,22 @@ describe('Soy', function() { it('should render and instantiate nested components even without ref', function() { comp = new NestedNoDataComponent(); assert.strictEqual(1, comp.element.childNodes.length); - assert.strictEqual('Hello World!', comp.element.childNodes[0].textContent); + assert.strictEqual( + 'Hello World!', + comp.element.childNodes[0].textContent + ); }); it('should render and instantiate nested components inside nested components', function() { comp = new NestedLevelsComponent({ - name: 'Foo' + name: 'Foo', }); - var nested = comp.components.nested; + let nested = comp.components.nested; assert.ok(nested instanceof NestedComponent); assert.strictEqual(nested.element, comp.element.childNodes[0]); - var nested2 = nested.components.hello; + let nested2 = nested.components.hello; assert.ok(nested2 instanceof HelloWorldComponent); assert.strictEqual(nested2.element, nested.element.childNodes[0]); assert.strictEqual('Hello Foo!', nested2.element.textContent); @@ -377,15 +392,15 @@ describe('Soy', function() { it('should render and instantiate multiple nested components', function() { comp = new NestedMultipleComponent({ - count: 2 + count: 2, }); - var nested1 = comp.components.hello1; + let nested1 = comp.components.hello1; assert.ok(nested1 instanceof HelloWorldComponent); assert.strictEqual(nested1.element, comp.element.childNodes[0]); assert.strictEqual('Hello World!', nested1.element.textContent); - var nested2 = comp.components.hello2; + let nested2 = comp.components.hello2; assert.ok(nested2 instanceof HelloWorldComponent); assert.strictEqual(nested2.element, comp.element.childNodes[1]); assert.strictEqual('Hello World!', nested2.element.textContent); @@ -394,18 +409,20 @@ describe('Soy', function() { describe('Soy.getTemplate', function() { it('should not throw error if called for undeclared namespace', function() { - assert.doesNotThrow(() => Soy.getTemplate('Undeclared.incrementaldom', 'render')); + assert.doesNotThrow(() => + Soy.getTemplate('Undeclared.incrementaldom', 'render') + ); }); it('should throw error if returned function is called for undeclared namespace', function() { - var template = Soy.getTemplate('Undeclared.incrementaldom', 'render'); + let template = Soy.getTemplate('Undeclared.incrementaldom', 'render'); assert.throws(template); }); it('should not throw error if namespace is declared before returned function is called', function() { - var template = Soy.getTemplate('DeclaredLater.incrementaldom', 'render'); - var module = { - render: sinon.stub() + let template = Soy.getTemplate('DeclaredLater.incrementaldom', 'render'); + let module = { + render: sinon.stub(), }; goog.loadModule(function() { goog.module('DeclaredLater.incrementaldom'); @@ -418,40 +435,40 @@ describe('Soy', function() { describe('Soy.toHtmlString', function() { it('should convert given incremental dom function into an html string', function() { - var fn = function() { + let fn = function() { IncrementalDOM.elementOpen('div', null, [], 'class', 'toHtmlString'); IncrementalDOM.text('To Convert'); IncrementalDOM.elementClose('div'); }; - var str = Soy.toHtmlString(fn); + let str = Soy.toHtmlString(fn); assert.strictEqual('
To Convert
', str); }); }); describe('Soy.toIncDom', function() { it('should convert given html string into an incremental dom function', function() { - var str = '
To Convert
'; - var fn = Soy.toIncDom(str); + let str = '
To Convert
'; + let fn = Soy.toIncDom(str); - var element = document.createElement('div'); + let element = document.createElement('div'); IncrementalDOM.patch(element, fn); assert.strictEqual(str, element.innerHTML); }); it('should convert given sanitized html object into an incremental dom function', function() { - var str = '
To Convert
'; - var fn = Soy.toIncDom({ + let str = '
To Convert
'; + let fn = Soy.toIncDom({ content: str, - contentKind: 'HTML' + contentKind: 'HTML', }); - var element = document.createElement('div'); + let element = document.createElement('div'); IncrementalDOM.patch(element, fn); assert.strictEqual(str, element.innerHTML); }); it('should not try to convert param that is not a string or a sanitized html object', function() { - var fn = sinon.stub(); + let fn = sinon.stub(); assert.strictEqual(fn, Soy.toIncDom(fn)); }); }); diff --git a/packages/metal-soy/test/SoyAop.js b/packages/metal-soy/test/SoyAop.js index fe5886da..7ab6ffc9 100644 --- a/packages/metal-soy/test/SoyAop.js +++ b/packages/metal-soy/test/SoyAop.js @@ -1,6 +1,6 @@ 'use strict'; -import { object } from 'metal'; +import {object} from 'metal'; import SoyAop from '../src/SoyAop'; describe('SoyAop', function() { @@ -9,16 +9,16 @@ describe('SoyAop', function() { }); it('should intercept calls to template functions that were registered', function() { - var templates = { + let templates = { fn1: sinon.stub(), fn2: sinon.stub(), - fn3: sinon.stub() + fn3: sinon.stub(), }; - var originals = object.mixin({}, templates); + let originals = object.mixin({}, templates); SoyAop.registerForInterception(templates, 'fn1'); SoyAop.registerForInterception(templates, 'fn2'); - var interceptor = sinon.stub(); + let interceptor = sinon.stub(); SoyAop.startInterception(interceptor); templates.fn1(); @@ -35,15 +35,15 @@ describe('SoyAop', function() { }); it('should get original function', function() { - var templates = { + let templates = { fn1: sinon.stub(), - fn2: sinon.stub() + fn2: sinon.stub(), }; - var originals = object.mixin({}, templates); + let originals = object.mixin({}, templates); SoyAop.registerForInterception(templates, 'fn1'); SoyAop.registerForInterception(templates, 'fn2'); - var interceptor = sinon.stub(); + let interceptor = sinon.stub(); SoyAop.startInterception(interceptor); assert.notStrictEqual(originals.fn1, templates.fn1); @@ -56,36 +56,42 @@ describe('SoyAop', function() { }); it('should pass correct params to intercepted call', function() { - var templates = { + let templates = { fn1: sinon.stub(), - fn2: sinon.stub() + fn2: sinon.stub(), }; SoyAop.registerForInterception(templates, 'fn1'); SoyAop.registerForInterception(templates, 'fn2'); - var interceptor = sinon.stub(); + let interceptor = sinon.stub(); SoyAop.startInterception(interceptor); - var data = {}; - var ijData = {}; + let data = {}; + let ijData = {}; templates.fn1(data, null, ijData); - assert.strictEqual(SoyAop.getOriginalFn(templates.fn1), interceptor.args[0][0]); + assert.strictEqual( + SoyAop.getOriginalFn(templates.fn1), + interceptor.args[0][0] + ); assert.strictEqual(data, interceptor.args[0][1]); assert.strictEqual(ijData, interceptor.args[0][3]); templates.fn2(data, null, ijData); - assert.strictEqual(SoyAop.getOriginalFn(templates.fn2), interceptor.args[1][0]); + assert.strictEqual( + SoyAop.getOriginalFn(templates.fn2), + interceptor.args[1][0] + ); assert.strictEqual(data, interceptor.args[1][1]); assert.strictEqual(ijData, interceptor.args[1][3]); }); it('should stop intercepting calls to template functions', function() { - var templates = { - fn: sinon.stub() + let templates = { + fn: sinon.stub(), }; SoyAop.registerForInterception(templates, 'fn'); - var interceptor = sinon.stub(); + let interceptor = sinon.stub(); SoyAop.startInterception(interceptor); SoyAop.stopInterception(interceptor); @@ -95,12 +101,12 @@ describe('SoyAop', function() { }); it('should restart intercepting calls to template functions', function() { - var templates = { - fn: sinon.stub() + let templates = { + fn: sinon.stub(), }; SoyAop.registerForInterception(templates, 'fn'); - var interceptor = sinon.stub(); + let interceptor = sinon.stub(); SoyAop.startInterception(interceptor); SoyAop.stopInterception(interceptor); SoyAop.startInterception(interceptor); @@ -111,13 +117,13 @@ describe('SoyAop', function() { }); it('should go back to previous intercepting function when interception is stopped', function() { - var templates = { - fn: sinon.stub() + let templates = { + fn: sinon.stub(), }; SoyAop.registerForInterception(templates, 'fn'); - var interceptor1 = sinon.stub(); - var interceptor2 = sinon.stub(); + let interceptor1 = sinon.stub(); + let interceptor2 = sinon.stub(); SoyAop.startInterception(interceptor1); SoyAop.startInterception(interceptor2); @@ -141,11 +147,11 @@ describe('SoyAop', function() { }); it('should register templates after interception has already started', function() { - var interceptor = sinon.stub(); + let interceptor = sinon.stub(); SoyAop.startInterception(interceptor); - var templates = { - fn: sinon.stub() + let templates = { + fn: sinon.stub(), }; SoyAop.registerForInterception(templates, 'fn'); @@ -157,12 +163,12 @@ describe('SoyAop', function() { it('should not replace template function if it has already been replaced', function() { SoyAop.startInterception(sinon.stub()); - var templates = { - fn: sinon.stub() + let templates = { + fn: sinon.stub(), }; SoyAop.registerForInterception(templates, 'fn'); - var replacedFn = templates.fn; + let replacedFn = templates.fn; SoyAop.registerForInterception(templates, 'fn'); assert.strictEqual(replacedFn, templates.fn); }); diff --git a/packages/metal-state/.eslintrc b/packages/metal-state/.eslintrc new file mode 100644 index 00000000..d4cadde2 --- /dev/null +++ b/packages/metal-state/.eslintrc @@ -0,0 +1,5 @@ +{ + "rules": { + "no-invalid-this": 0 + } +} \ No newline at end of file diff --git a/packages/metal-state/package-lock.json b/packages/metal-state/package-lock.json index f9c637f5..7e4c66d6 100644 --- a/packages/metal-state/package-lock.json +++ b/packages/metal-state/package-lock.json @@ -64,7 +64,7 @@ "lodash": "4.17.4", "minimatch": "3.0.4", "path-is-absolute": "1.0.1", - "private": "0.1.7", + "private": "0.1.8", "slash": "1.0.0", "source-map": "0.5.7" } @@ -507,9 +507,9 @@ } }, "babel-preset-env": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/babel-preset-env/-/babel-preset-env-1.6.0.tgz", - "integrity": "sha512-OVgtQRuOZKckrILgMA5rvctvFZPv72Gua9Rt006AiPoB0DJKGN07UmaQA+qRrYgK71MVct8fFhT0EyNWYorVew==", + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/babel-preset-env/-/babel-preset-env-1.6.1.tgz", + "integrity": "sha512-W6VIyA6Ch9ePMI7VptNn2wBM6dbG0eSz25HEiL40nQXCsXGTGZSTZu1Iap+cj3Q0S5a7T9+529l/5Bkvd+afNA==", "requires": { "babel-plugin-check-es2015-constants": "6.22.0", "babel-plugin-syntax-trailing-function-commas": "6.22.0", @@ -538,7 +538,7 @@ "babel-plugin-transform-es2015-unicode-regex": "6.24.1", "babel-plugin-transform-exponentiation-operator": "6.24.1", "babel-plugin-transform-regenerator": "6.26.0", - "browserslist": "2.5.1", + "browserslist": "2.8.0", "invariant": "2.2.2", "semver": "5.4.1" } @@ -625,18 +625,18 @@ } }, "browserslist": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-2.5.1.tgz", - "integrity": "sha512-jAvM2ku7YDJ+leAq3bFH1DE0Ylw+F+EQDq4GkqZfgPEqpWYw9ofQH85uKSB9r3Tv7XDbfqVtE+sdvKJW7IlPJA==", + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-2.8.0.tgz", + "integrity": "sha512-iiWHM1Et6Q4TQpB7Ar6pxuM3TNMXasVJY4Y/oh3q38EwR3Z+IdZ9MyVf7PI4MJFB4xpwMcZgs9bEUnPG2E3TCA==", "requires": { - "caniuse-lite": "1.0.30000746", - "electron-to-chromium": "1.3.25" + "caniuse-lite": "1.0.30000760", + "electron-to-chromium": "1.3.27" } }, "caniuse-lite": { - "version": "1.0.30000746", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000746.tgz", - "integrity": "sha1-xk+Vo5Jc/TAgejCO12wa6W6gnqA=" + "version": "1.0.30000760", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000760.tgz", + "integrity": "sha1-7HIDlXQvHH7IlH/W3SYE53qPmP8=" }, "chalk": { "version": "1.1.3", @@ -687,9 +687,9 @@ } }, "electron-to-chromium": { - "version": "1.3.25", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.25.tgz", - "integrity": "sha1-RTshAJg20Jl9hgNWAf9srkeRxGA=" + "version": "1.3.27", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.27.tgz", + "integrity": "sha1-eOy4o5kGYYe7N07t412ccFZagD0=" }, "escape-string-regexp": { "version": "1.0.5", @@ -879,9 +879,9 @@ "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" }, "private": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/private/-/private-0.1.7.tgz", - "integrity": "sha1-aM5eih7woju1cMwoU3tTMqumPvE=" + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/private/-/private-0.1.8.tgz", + "integrity": "sha512-VvivMrbvd2nKkiG38qjULzlc+4Vx4wm/whI9pQD35YrARNnhxeiRktSOhSukRLFNlzg6Br/cJPet5J/u19r/mg==" }, "regenerate": { "version": "1.3.3", @@ -900,7 +900,7 @@ "requires": { "babel-runtime": "6.26.0", "babel-types": "6.26.0", - "private": "0.1.7" + "private": "0.1.8" } }, "regexpu-core": { diff --git a/packages/metal-state/src/Config.js b/packages/metal-state/src/Config.js index 2e3826cb..2e460902 100644 --- a/packages/metal-state/src/Config.js +++ b/packages/metal-state/src/Config.js @@ -1,6 +1,6 @@ 'use strict'; -import { object } from 'metal'; +import {object} from 'metal'; import validators from './validators'; /** @@ -28,9 +28,9 @@ import validators from './validators'; */ const Config = { /** - * An object that contains a validator function. - * @typedef {!Object} ConfigWithValidator - */ + * An object that contains a validator function. + * @typedef {!Object} ConfigWithValidator + */ /** * Function that creates `State` object with an `any` validator. @@ -127,12 +127,12 @@ const Config = { /** * Adds the `internal` flag to the `State` configuration. - * @param {boolean} required Flag to set "internal" to. True by default. + * @param {boolean} internal Flag to set "internal" to. True by default. * @return {!Object} `State` configuration object. */ internal(internal = true) { return mergeConfig(this, { - internal + internal, }); }, @@ -143,7 +143,7 @@ const Config = { */ required(required = true) { return mergeConfig(this, { - required + required, }); }, @@ -154,7 +154,7 @@ const Config = { */ setter(setter) { return mergeConfig(this, { - setter + setter, }); }, @@ -165,7 +165,7 @@ const Config = { */ validator(validator) { return mergeConfig(this, { - validator + validator, }); }, @@ -176,7 +176,7 @@ const Config = { */ value(value) { return mergeConfig(this, { - value + value, }); }, @@ -187,7 +187,7 @@ const Config = { */ valueFn(valueFn) { return mergeConfig(this, { - valueFn + valueFn, }); }, @@ -198,9 +198,9 @@ const Config = { */ writeOnce(writeOnce = false) { return mergeConfig(this, { - writeOnce + writeOnce, }); - } + }, }; /** @@ -213,13 +213,14 @@ function destructShapeOfConfigs(shape) { const retShape = {}; - keys.forEach( - key => { - const value = shape[key]; + keys.forEach(key => { + const value = shape[key]; - retShape[key] = value.config && value.config.validator ? value.config.validator : destructShapeOfConfigs(value); - } - ); + retShape[key] = + value.config && value.config.validator + ? value.config.validator + : destructShapeOfConfigs(value); + }); return retShape; } @@ -241,10 +242,10 @@ function mergeConfig(context, config) { } /** -* Calls validators with provided argument. -* @param {string} name The name of the validator. -* @param {!function()} -*/ + * Calls validators with provided argument. + * @param {string} name The name of the validator. + * @return {function()} + */ function setExplicitValueValidators(name) { return function(arg) { return this.validator(validators[name](arg)); @@ -252,10 +253,10 @@ function setExplicitValueValidators(name) { } /** -* Calls validators with a single nested config. -* @param {string} name The name of the validator. -* @return {!function()} -*/ + * Calls validators with a single nested config. + * @param {string} name The name of the validator. + * @return {!function()} + */ function setNestedValidators(name) { return function(arg) { return this.validator(validators[name](arg.config.validator)); @@ -263,10 +264,10 @@ function setNestedValidators(name) { } /** -* Adds primitive type validators to the config object. -* @param {string} name The name of the validator. -* @return {!function()} -*/ + * Adds primitive type validators to the config object. + * @param {string} name The name of the validator. + * @return {!function()} + */ function setPrimitiveValidators(name) { return function() { return this.validator(validators[name]); diff --git a/packages/metal-state/src/State.js b/packages/metal-state/src/State.js index 47bacb66..795b8ce4 100644 --- a/packages/metal-state/src/State.js +++ b/packages/metal-state/src/State.js @@ -1,7 +1,16 @@ 'use strict'; -import { async, getStaticProperty, isDef, isDefAndNotNull, isFunction, isObject, isString, object } from 'metal'; -import { EventEmitter } from 'metal-events'; +import { + async, + getStaticProperty, + isDef, + isDefAndNotNull, + isFunction, + isObject, + isString, + object, +} from 'metal'; +import {EventEmitter} from 'metal-events'; /** * State adds support for having object properties that can be watched for @@ -13,15 +22,15 @@ import { EventEmitter } from 'metal-events'; class State extends EventEmitter { /** * Constructor function for `State`. - * @param {Object=} opt_config Optional config object with initial values to + * @param {Object=} config Optional config object with initial values to * set state properties to. - * @param {Object=} opt_obj Optional object that should hold the state + * @param {Object=} obj Optional object that should hold the state * properties. If none is given, they will be added directly to `this` * instead. - * @param {Object=} opt_context Optional context to call functions (like + * @param {Object=} context Optional context to call functions (like * validators and setters) on. Defaults to `this`. */ - constructor(opt_config, opt_obj, opt_context) { + constructor(config, obj, context) { super(); /** @@ -29,7 +38,7 @@ class State extends EventEmitter { * @type {!Object} * @protected */ - this.context_ = opt_context || this; + this.context_ = context || this; /** * Map of keys that can not be used as state keys. @@ -43,7 +52,7 @@ class State extends EventEmitter { * @type {!Object} * @protected */ - this.obj_ = opt_obj || this; + this.obj_ = obj || this; this.eventData_ = null; @@ -64,7 +73,7 @@ class State extends EventEmitter { this.stateConfigs_ = {}; - this.initialValues_ = object.mixin({}, opt_config); + this.initialValues_ = object.mixin({}, config); this.setShouldUseFacade(true); this.configStateFromStaticHint_(); @@ -72,7 +81,7 @@ class State extends EventEmitter { Object.defineProperty(this.obj_, State.STATE_REF_KEY, { configurable: true, enumerable: false, - value: this + value: this, }); } @@ -85,11 +94,14 @@ class State extends EventEmitter { const config = this.stateConfigs_[name]; if (config.required) { const info = this.getStateInfo(name); - const value = info.state === State.KeyStates.INITIALIZED ? - this.get(name) : - this.initialValues_[name]; + const value = + info.state === State.KeyStates.INITIALIZED + ? this.get(name) + : this.initialValues_[name]; if (!isDefAndNotNull(value)) { - let errorMessage = `The property called "${name}" is required but didn't receive a value.`; + let errorMessage = `The property called "${ + name + }" is required but didn't receive a value.`; if (this.shouldThrowValidationError()) { throw new Error(errorMessage); } else { @@ -144,7 +156,7 @@ class State extends EventEmitter { }, set: function(val) { this[State.STATE_REF_KEY].setStateKeyValue_(name, val); - } + }, }; } @@ -152,14 +164,14 @@ class State extends EventEmitter { * Calls the requested function, running the appropriate code for when it's * passed as an actual function object or just the function's name. * @param {!Function|string} fn Function, or name of the function to run. - * @param {!Array} An optional array of parameters to be passed to the + * @param {!Array} args optional array of parameters to be passed to the * function that will be called. * @return {*} The return value of the called function. * @protected */ callFunction_(fn, args) { if (isString(fn)) { - return this.context_[fn].apply(this.context_, args); + return this.context_[fn].apply(this.context_, args); // eslint-disable-line } else if (isFunction(fn)) { return fn.apply(this.context_, args); } @@ -192,10 +204,11 @@ class State extends EventEmitter { callValidator_(name, value) { const config = this.stateConfigs_[name]; if (config.validator) { - const validatorReturn = this.callFunction_( - config.validator, - [value, name, this.context_] - ); + const validatorReturn = this.callFunction_(config.validator, [ + value, + name, + this.context_, + ]); this.assertValidatorReturnInstanceOfError_(validatorReturn); return validatorReturn; } @@ -237,33 +250,32 @@ class State extends EventEmitter { * first time. * @param {!Object.|string} configs An object that maps * configuration options for keys to be added to the state. - * @param {boolean|Object|*=} opt_context The context where the added state + * @param {boolean|Object|*=} context The context where the added state * keys will be defined (defaults to `this`), or false if they shouldn't * be defined at all. */ - configState(configs, opt_context) { + configState(configs, context) { const names = Object.keys(configs); if (names.length === 0) { return; } - if (opt_context !== false) { + if (context !== false) { const props = {}; for (let i = 0; i < names.length; i++) { const name = names[i]; this.assertValidStateKeyName_(name); props[name] = this.buildKeyPropertyDef_(name); } - Object.defineProperties( - opt_context || this.obj_, - props - ); + Object.defineProperties(context || this.obj_, props); } this.stateConfigs_ = configs; for (let i = 0; i < names.length; i++) { const name = names[i]; - configs[name] = configs[name].config ? configs[name].config : configs[name]; + configs[name] = configs[name].config + ? configs[name].config + : configs[name]; this.assertGivenIfRequired_(names[i]); this.validateInitialValue_(names[i]); } @@ -282,8 +294,7 @@ class State extends EventEmitter { ctor[staticKey] = ctor[staticKey] || {}; - defineContext = ctor[staticKey][ctor.name] ? false : - ctor.prototype; + defineContext = ctor[staticKey][ctor.name] ? false : ctor.prototype; // eslint-disable-line ctor[staticKey][ctor.name] = true; } this.configState(State.getStateStatic(ctor), defineContext); @@ -329,13 +340,12 @@ class State extends EventEmitter { /** * Returns an object that maps state keys to their values. - * @param {Array=} opt_names A list of names of the keys that should + * @param {Array=} names A list of names of the keys that should * be returned. If none is given, the whole state will be returned. * @return {Object.} */ - getState(opt_names) { + getState(names = this.getStateKeys()) { const state = {}; - const names = opt_names || this.getStateKeys(); for (let i = 0; i < names.length; i++) { state[names[i]] = this.get(names[i]); @@ -406,8 +416,9 @@ class State extends EventEmitter { */ hasBeenSet(name) { const info = this.getStateInfo(name); - return info.state === State.KeyStates.INITIALIZED || - this.hasInitialValue_(name); + return ( + info.state === State.KeyStates.INITIALIZED || this.hasInitialValue_(name) // eslint-disable-line + ); } /** @@ -417,8 +428,10 @@ class State extends EventEmitter { * @protected */ hasInitialValue_(name) { - return this.initialValues_.hasOwnProperty(name) && - isDef(this.initialValues_[name]); + return ( + this.initialValues_.hasOwnProperty(name) && + isDef(this.initialValues_[name]) + ); } /** @@ -441,11 +454,14 @@ class State extends EventEmitter { */ informChange_(name, prevVal) { if (this.shouldInformChange_(name, prevVal)) { - const data = object.mixin({ - key: name, - newVal: this.get(name), - prevVal: prevVal - }, this.eventData_); + const data = object.mixin( + { + key: name, + newVal: this.get(name), + prevVal: prevVal, + }, + this.eventData_ + ); this.context_.emit(`${name}Changed`, data); this.context_.emit('stateKeyChanged', data); this.scheduleBatchEvent_(data); @@ -500,9 +516,12 @@ class State extends EventEmitter { scheduleBatchEvent_(changeData) { if (!this.scheduledBatchData_) { async.nextTick(this.emitBatchEvent_, this); - this.scheduledBatchData_ = object.mixin({ - changes: {} - }, this.eventData_); + this.scheduledBatchData_ = object.mixin( + { + changes: {}, + }, + this.eventData_ + ); } const name = changeData.key; @@ -521,7 +540,6 @@ class State extends EventEmitter { * actually needed. * @param {string} name * @param {*} value - * @return {*} */ set(name, value) { if (this.hasStateKey(name)) { @@ -532,7 +550,6 @@ class State extends EventEmitter { /** * Sets the default value of the requested state key. * @param {string} name The name of the key. - * @return {*} */ setDefaultValue(name) { const config = this.stateConfigs_[name]; @@ -546,7 +563,7 @@ class State extends EventEmitter { /** * Sets data to be sent with all events emitted from this instance. - * @param {Object} + * @param {Object} data */ setEventData(data) { this.eventData_ = data; @@ -555,7 +572,6 @@ class State extends EventEmitter { /** * Sets the initial value of the requested state key. * @param {string} name The name of the key. - * @return {*} * @protected */ setInitialValue_(name) { @@ -567,7 +583,7 @@ class State extends EventEmitter { /** * Sets a map of keys that are not valid state keys. - * @param {!Object} + * @param {!Object} blacklist */ setKeysBlacklist(blacklist) { this.keysBlacklist_ = blacklist; @@ -577,13 +593,13 @@ class State extends EventEmitter { * Sets the value of all the specified state keys. * @param {!Object.} values A map of state keys to the values they * should be set to. - * @param {function()=} opt_callback An optional function that will be run + * @param {function()=} callback An optional function that will be run * after the next batched update is triggered. */ - setState(values, opt_callback) { + setState(values, callback) { Object.keys(values).forEach(name => this.set(name, values[name])); - if (opt_callback && this.scheduledBatchData_) { - this.context_.once('stateChanged', opt_callback); + if (callback && this.scheduledBatchData_) { + this.context_.once('stateChanged', callback); } } @@ -596,9 +612,11 @@ class State extends EventEmitter { * @protected */ setStateKeyValue_(name, value) { - if (this.warnIfDisposed_(name) || + if ( + this.warnIfDisposed_(name) || !this.canSetState(name) || - !this.validateKeyValue_(name, value)) { + !this.validateKeyValue_(name, value) + ) { return; } @@ -624,8 +642,10 @@ class State extends EventEmitter { */ shouldInformChange_(name, prevVal) { const info = this.getStateInfo(name); - return (info.state === State.KeyStates.INITIALIZED) && - (isObject(prevVal) || prevVal !== this.get(name)); + return ( + info.state === State.KeyStates.INITIALIZED && + (isObject(prevVal) || prevVal !== this.get(name)) + ); } /** @@ -643,9 +663,10 @@ class State extends EventEmitter { * @protected */ validateInitialValue_(name) { - if (this.initialValues_.hasOwnProperty(name) && - !this.callValidator_(name, this.initialValues_[name])) { - + if ( + this.initialValues_.hasOwnProperty(name) && + !this.callValidator_(name, this.initialValues_[name]) + ) { delete this.initialValues_[name]; } } @@ -660,8 +681,10 @@ class State extends EventEmitter { */ validateKeyValue_(name, value) { const info = this.getStateInfo(name); - return info.state === State.KeyStates.INITIALIZING || - this.callValidator_(name, value); + return ( + info.state === State.KeyStates.INITIALIZING || + this.callValidator_(name, value) + ); } /** @@ -702,7 +725,7 @@ State.STATE_STATIC_HINT_CONFIGURED = '__METAL_STATE_STATIC_HINT_CONFIGURED__'; State.KeyStates = { UNINITIALIZED: undefined, INITIALIZING: 1, - INITIALIZED: 2 + INITIALIZED: 2, }; export default State; diff --git a/packages/metal-state/src/all/state.js b/packages/metal-state/src/all/state.js index d4694fea..ef616a46 100644 --- a/packages/metal-state/src/all/state.js +++ b/packages/metal-state/src/all/state.js @@ -5,4 +5,4 @@ import Config from '../Config'; import State from '../State'; export default State; -export { validators, Config, State }; +export {validators, Config, State}; diff --git a/packages/metal-state/src/validators.js b/packages/metal-state/src/validators.js index 7c57ce3a..677ea57a 100644 --- a/packages/metal-state/src/validators.js +++ b/packages/metal-state/src/validators.js @@ -1,6 +1,6 @@ 'use strict'; -import { getFunctionName, isDefAndNotNull } from 'metal'; +import {getFunctionName, isDefAndNotNull} from 'metal'; const ERROR_ARRAY_OF_TYPE = 'Expected an array of single type.'; const ERROR_OBJECT_OF_TYPE = 'Expected object of one type.'; @@ -83,10 +83,9 @@ const validators = { if (isInvalid(result)) { return result; } - return arrayOfValues.indexOf(value) === -1 ? - composeError( - composeOneOfErrorMessage(arrayOfValues), name, context - ) : true; + return arrayOfValues.indexOf(value) === -1 + ? composeError(composeOneOfErrorMessage(arrayOfValues), name, context) // eslint-disable-line + : true; }); }, @@ -99,12 +98,13 @@ const validators = { */ oneOfType: function(arrayOfTypeValidators) { return maybe((value, name, context) => { - const result = validators.array(arrayOfTypeValidators, name, context); + const result = validators.array(arrayOfTypeValidators, name, context); // eslint-disable-line if (isInvalid(result)) { return result; } for (let i = 0; i < arrayOfTypeValidators.length; i++) { + // eslint-disable-next-line if (!isInvalid(arrayOfTypeValidators[i](value, name, context))) { return true; } @@ -127,20 +127,24 @@ const validators = { } for (let key in shape) { - let validator = shape[key]; - let required = false; - if (validator.config) { - required = validator.config.required; - validator = validator.config.validator; - } - if ((required && !isDefAndNotNull(value[key])) || - isInvalid(validator(value[key]))) { - return composeError(ERROR_SHAPE_OF, name, context); + if (Object.prototype.hasOwnProperty.call(shape, key)) { + let validator = shape[key]; + let required = false; + if (validator.config) { + required = validator.config.required; + validator = validator.config.validator; + } + if ( + (required && !isDefAndNotNull(value[key])) || + isInvalid(validator(value[key])) + ) { + return composeError(ERROR_SHAPE_OF, name, context); + } } } return true; }); - } + }, }; /** @@ -181,7 +185,7 @@ function composeError(error, name, context) { const location = parentName ? `Check render method of '${parentName}'.` : ''; return new Error( `Warning: Invalid state passed to '${name}'. ` + - `${error} Passed to '${compName}'. ${location}` + `${error} Passed to '${compName}'. ${location}` ); } @@ -221,11 +225,10 @@ function isInvalid(result) { */ function maybe(typeValidator) { return (value, name, context) => { - return isDefAndNotNull(value) ? typeValidator(value, name, context) : true; + return isDefAndNotNull(value) ? typeValidator(value, name, context) : true; // eslint-disable-line }; } - /** * Checks if all the items of the given array pass the given validator. * @param {!function()} validator diff --git a/packages/metal-state/test/.eslintrc b/packages/metal-state/test/.eslintrc new file mode 100644 index 00000000..f6269b7a --- /dev/null +++ b/packages/metal-state/test/.eslintrc @@ -0,0 +1,14 @@ +{ + "env": { + "mocha": true + }, + "globals": { + "assert": true, + "sinon": true + }, + "rules": { + "max-len": 0, + "no-invalid-this": 0, + "require-jsdoc": 0 + } +} \ No newline at end of file diff --git a/packages/metal-state/test/.eslintrc.json b/packages/metal-state/test/.eslintrc.json deleted file mode 100644 index 92b466f1..00000000 --- a/packages/metal-state/test/.eslintrc.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "env": { - "mocha": true - }, - "globals": { - "assert": true, - "sinon": true - } -} diff --git a/packages/metal-state/test/Config.js b/packages/metal-state/test/Config.js index 23c17dec..3e3dcea0 100644 --- a/packages/metal-state/test/Config.js +++ b/packages/metal-state/test/Config.js @@ -5,102 +5,121 @@ import Config from '../src/Config'; describe('Config', function() { it('should return config with "internal" flag set to true by default', function() { - var config = Config.internal(); + let config = Config.internal(); assert.ok(core.isObject(config)); - var expected = { - internal: true + let expected = { + internal: true, }; assert.deepEqual(expected, config.config); }); it('should return config with "internal" flag set to the given vaue', function() { - var internal = false; - var config = Config.internal(internal); + let internal = false; + let config = Config.internal(internal); assert.ok(core.isObject(config)); - assert.deepEqual({ - internal - }, config.config); + assert.deepEqual( + { + internal, + }, + config.config + ); }); it('should return config with "required" flag set to true by default', function() { - var config = Config.required(); + let config = Config.required(); assert.ok(core.isObject(config)); - var expected = { - required: true + let expected = { + required: true, }; assert.deepEqual(expected, config.config); }); it('should return config with "required" flag set to the given vaue', function() { - var required = false; - var config = Config.required(required); + let required = false; + let config = Config.required(required); assert.ok(core.isObject(config)); - assert.deepEqual({ - required - }, config.config); + assert.deepEqual( + { + required, + }, + config.config + ); }); it('should return config with specified "value"', function() { - var value = 10; - var config = Config.value(10); + let value = 10; + let config = Config.value(10); assert.ok(core.isObject(config)); - assert.deepEqual({ - value - }, config.config); + assert.deepEqual( + { + value, + }, + config.config + ); }); it('should return config with specified "valueFn"', function() { - var valueFn = () => {}; - var config = Config.valueFn(valueFn); + let valueFn = () => {}; + let config = Config.valueFn(valueFn); assert.ok(core.isObject(config)); - assert.deepEqual({ - valueFn - }, config.config); + assert.deepEqual( + { + valueFn, + }, + config.config + ); }); it('should return config with "writeOnce" flag set to false by default', function() { - var config = Config.writeOnce(); + let config = Config.writeOnce(); assert.ok(core.isObject(config)); - var expected = { - writeOnce: false + let expected = { + writeOnce: false, }; assert.deepEqual(expected, config.config); }); it('should return config with "writeOnce" flag set to the given vaue', function() { - var writeOnce = true; - var config = Config.writeOnce(writeOnce); + let writeOnce = true; + let config = Config.writeOnce(writeOnce); assert.ok(core.isObject(config)); - assert.deepEqual({ - writeOnce - }, config.config); + assert.deepEqual( + { + writeOnce, + }, + config.config + ); }); it('should return config with specified "setter"', function() { - var setter = () => { - }; - var config = Config.setter(setter); + let setter = () => {}; + let config = Config.setter(setter); assert.ok(core.isObject(config)); - assert.deepEqual({ - setter - }, config.config); + assert.deepEqual( + { + setter, + }, + config.config + ); }); it('should return config with specified "validator"', function() { - var validator = () => { - }; - var config = Config.validator(validator); + let validator = () => {}; + let config = Config.validator(validator); assert.ok(core.isObject(config)); - assert.deepEqual({ - validator - }, config.config); + assert.deepEqual( + { + validator, + }, + config.config + ); }); it('should return config with "any" validator from "validators"', function() { - var config = Config.any(); + let config = Config.any(); assert.ok(core.isObject(config)); assert.ok(core.isFunction(config.config.validator)); assert.ok(config.config.validator(10)); @@ -108,7 +127,7 @@ describe('Config', function() { }); it('should return config with "array" validator from "validators"', function() { - var config = Config.array(); + let config = Config.array(); assert.ok(core.isObject(config)); assert.ok(core.isFunction(config.config.validator)); assert.ok(config.config.validator(['one'])); @@ -116,7 +135,7 @@ describe('Config', function() { }); it('should return config with "arrayOf" validator from "validators"', function() { - var config = Config.arrayOf(Config.number()); + let config = Config.arrayOf(Config.number()); assert.ok(core.isObject(config)); assert.ok(core.isFunction(config.config.validator)); assert.ok(config.config.validator([1, 2])); @@ -125,7 +144,7 @@ describe('Config', function() { }); it('should return config with "bool" validator from "validators"', function() { - var config = Config.bool(); + let config = Config.bool(); assert.ok(core.isObject(config)); assert.ok(core.isFunction(config.config.validator)); assert.ok(config.config.validator(true)); @@ -133,7 +152,7 @@ describe('Config', function() { }); it('should return config with "func" validator from "validators"', function() { - var config = Config.func(); + let config = Config.func(); assert.ok(core.isObject(config)); assert.ok(core.isFunction(config.config.validator)); assert.ok(config.config.validator(function() {})); @@ -141,12 +160,10 @@ describe('Config', function() { }); it('should return config with "instanceOf" validator from "validators"', function() { - class TestClass { - } - class TestClass2 { - } + class TestClass {} + class TestClass2 {} - var config = Config.instanceOf(TestClass); + let config = Config.instanceOf(TestClass); assert.ok(core.isObject(config)); assert.ok(core.isFunction(config.config.validator)); assert.ok(config.config.validator(new TestClass())); @@ -154,7 +171,7 @@ describe('Config', function() { }); it('should return config with "number" validator from "validators"', function() { - var config = Config.number(); + let config = Config.number(); assert.ok(core.isObject(config)); assert.ok(core.isFunction(config.config.validator)); assert.ok(config.config.validator(10)); @@ -162,7 +179,7 @@ describe('Config', function() { }); it('should return config with "object" validator from "validators"', function() { - var config = Config.object(); + let config = Config.object(); assert.ok(core.isObject(config)); assert.ok(core.isFunction(config.config.validator)); assert.ok(config.config.validator({})); @@ -170,7 +187,7 @@ describe('Config', function() { }); it('should return config with "objectOf" validator from "validators"', function() { - var config = Config.objectOf(Config.number()); + let config = Config.objectOf(Config.number()); assert.ok(core.isObject(config)); assert.ok(core.isFunction(config.config.validator)); assert.ok(config.config.validator({foo: 1})); @@ -178,25 +195,25 @@ describe('Config', function() { }); it('should return config with "oneOf" validator from "validators"', function() { - var config = Config.oneOf([1, 'one']); - assert.ok(core.isObject(config)); - assert.ok(core.isFunction(config.config.validator)); - assert.ok(config.config.validator(1)); - assert.ok(config.config.validator('one')); - assert.ok(config.config.validator(2) instanceof Error); - assert.ok(config.config.validator(false) instanceof Error); - - var config = Config.oneOf([1, 'one']).required(); - assert.ok(core.isObject(config)); - assert.ok(core.isFunction(config.config.validator)); - assert.ok(config.config.validator(1)); - assert.ok(config.config.validator('one')); - assert.ok(config.config.validator(2) instanceof Error); - assert.ok(config.config.validator(false) instanceof Error); + const config1 = Config.oneOf([1, 'one']); + assert.ok(core.isObject(config1)); + assert.ok(core.isFunction(config1.config.validator)); + assert.ok(config1.config.validator(1)); + assert.ok(config1.config.validator('one')); + assert.ok(config1.config.validator(2) instanceof Error); + assert.ok(config1.config.validator(false) instanceof Error); + + const config2 = Config.oneOf([1, 'one']).required(); + assert.ok(core.isObject(config2)); + assert.ok(core.isFunction(config2.config.validator)); + assert.ok(config2.config.validator(1)); + assert.ok(config2.config.validator('one')); + assert.ok(config2.config.validator(2) instanceof Error); + assert.ok(config2.config.validator(false) instanceof Error); }); it('should return config with "oneOfType" validator from "validators"', function() { - var config = Config.oneOfType([Config.string(), Config.number()]); + let config = Config.oneOfType([Config.string(), Config.number()]); assert.ok(core.isObject(config)); assert.ok(core.isFunction(config.config.validator)); assert.ok(config.config.validator(1)); @@ -206,37 +223,37 @@ describe('Config', function() { }); it('should return config with "shapeOf" validator from "validators"', function() { - var shape = { + let shape = { one: Config.string(), two: { three: { - four: Config.number() - } + four: Config.number(), + }, }, - five: Config.arrayOf(Config.string()) + five: Config.arrayOf(Config.string()), }; - var pass = { + let pass = { one: 'one', two: { three: { - four: 4 - } + four: 4, + }, }, - five: ['five'] + five: ['five'], }; - var fail = { + let fail = { one: 'one', two: { three: { - four: 'four' - } + four: 'four', + }, }, - five: 5 + five: 5, }; - var config = Config.arrayOf(Config.shapeOf(shape)); + let config = Config.arrayOf(Config.shapeOf(shape)); assert.ok(core.isObject(config)); assert.ok(core.isFunction(config.config.validator)); assert.ok(config.config.validator(pass)); @@ -244,7 +261,7 @@ describe('Config', function() { }); it('should return config with "string" validator from "validators"', function() { - var config = Config.string(); + let config = Config.string(); assert.ok(core.isObject(config)); assert.ok(core.isFunction(config.config.validator)); assert.ok(config.config.validator('test')); @@ -252,9 +269,11 @@ describe('Config', function() { }); it('should return config with data from multiple calls', function() { - var setter = () => { - }; - var config = Config.required(true).number().value(10).setter(setter); + let setter = () => {}; + let config = Config.required(true) + .number() + .value(10) + .setter(setter); assert.ok(core.isObject(config)); assert.strictEqual(4, Object.keys(config.config).length); diff --git a/packages/metal-state/test/State.js b/packages/metal-state/test/State.js index 2a1e5fdd..1ff6eb43 100644 --- a/packages/metal-state/test/State.js +++ b/packages/metal-state/test/State.js @@ -1,90 +1,89 @@ 'use strict'; -import { async } from 'metal'; +import {async} from 'metal'; import EventEmitter from 'metal-events'; import State from '../src/State'; describe('State', function() { it('should add keys to the state', function() { - var state = new State(); + let state = new State(); state.configState({ key1: {}, - key2: {} + key2: {}, }); - var keys = Object.keys(state.getState()); + let keys = Object.keys(state.getState()); assert.strictEqual(2, keys.length); assert.strictEqual('key1', keys[0]); assert.strictEqual('key2', keys[1]); }); it('should make state keys enumerable', function() { - var state = new State(); + let state = new State(); state.configState({ key1: {}, - key2: {} + key2: {}, }); - var keys = Object.keys(state); + let keys = Object.keys(state); assert.notStrictEqual(-1, keys.indexOf('key1')); assert.notStrictEqual(-1, keys.indexOf('key2')); }); it('should not allow adding state key with name contained in key blacklist', function() { - class Test extends State { - } + class Test extends State {} - var test = new Test(); + let test = new Test(); test.setKeysBlacklist({ - invalid: true + invalid: true, }); assert.throws(function() { test.configState({ - invalid: {} + invalid: {}, }); }); }); it('should get a state key\'s config object', function() { - var state = new State(); + let state = new State(); state.configState({ key1: { - a: 2 - } + a: 2, + }, }); - var expected = { - a: 2 + let expected = { + a: 2, }; assert.deepEqual(expected, state.getStateKeyConfig('key1')); }); it('should use config object from "config" key', function() { - var state = new State(); + let state = new State(); state.configState({ key1: { config: { - a: 2 - } - } + a: 2, + }, + }, }); - var expected = { - a: 2 + let expected = { + a: 2, }; assert.deepEqual(expected, state.getStateKeyConfig('key1')); }); it('should return null if requesting config object of non existing key', function() { - var state = new State(); + let state = new State(); assert.strictEqual(undefined, state.getStateKeyConfig('key1')); }); it('should set and get state values', function() { - var state = new State(); + let state = new State(); state.configState({ key1: {}, - key2: {} + key2: {}, }); assert.strictEqual(undefined, state.key1); @@ -98,22 +97,22 @@ describe('State', function() { }); it('should get state key value through "get" method', function() { - var state = new State(); + let state = new State(); state.configState({ key1: { - value: 2 - } + value: 2, + }, }); assert.strictEqual(2, state.get('key1')); }); it('should set state key value through "set" method', function() { - var state = new State(); + let state = new State(); state.configState({ key1: { - value: 2 - } + value: 2, + }, }); state.set('key1', 3); @@ -121,97 +120,95 @@ describe('State', function() { }); it('should set default state key value', function() { - var state = createStateInstance(); + let state = createStateInstance(); assert.strictEqual(1, state.key1); assert.strictEqual(2, state.key2); }); it('should set default state key value with raw value', function() { - var state = new State(); + let state = new State(); state.configState({ key1: { - value: 1 - } + value: 1, + }, }); assert.strictEqual(1, state.key1); }); it('should set default state key value from function', function() { - var state = new State(); + let state = new State(); state.configState({ key1: { valueFn: function() { return 1; - } - } + }, + }, }); assert.strictEqual(1, state.key1); }); it('should set default state key value from function name', function() { - var state = new State(); + let state = new State(); state.returns1 = function() { return 1; }; state.configState({ key1: { - valueFn: 'returns1' - } + valueFn: 'returns1', + }, }); assert.strictEqual(1, state.key1); }); it('should ignore invalid valueFn function', function() { - var state = new State(); + let state = new State(); state.configState({ key1: { - valueFn: 1 - } + valueFn: 1, + }, }); assert.strictEqual(undefined, state.key1); }); it('should not use valueFn function if value is also defined', function() { - var state = new State(); + let state = new State(); state.configState({ key1: { value: '', valueFn: function() { return '1'; - } - } + }, + }, }); assert.strictEqual('', state.key1); }); it('should override default state key value', function() { - var state = new State({ + let state = new State({ key1: 10, - key2: 20 + key2: 20, + }); + state.configState({ + key1: { + value: 1, + }, + key2: { + value: 2, + }, }); - state.configState( - { - key1: { - value: 1 - }, - key2: { - value: 2 - } - } - ); assert.strictEqual(10, state.key1); assert.strictEqual(20, state.key2); }); it('should change initial state key value', function() { - var state = createStateInstance(); + let state = createStateInstance(); state.key1 = 10; @@ -219,12 +216,12 @@ describe('State', function() { }); it('should initialize state values lazily', function() { - var state = new State(); - var valueFn = sinon.stub().returns(2); + let state = new State(); + let valueFn = sinon.stub().returns(2); state.configState({ key1: { - valueFn: valueFn - } + valueFn: valueFn, + }, }); assert.strictEqual(0, valueFn.callCount); @@ -233,10 +230,12 @@ describe('State', function() { assert.strictEqual(1, valueFn.callCount); }); - it('should pass value, name and context args to validator function', function(done) { - var state = new State(); - var keyName = 'key1'; - var value = 2; + it('should pass value, name and context args to validator function', function( + done + ) { + let state = new State(); + let keyName = 'key1'; + let value = 2; state.configState({ [keyName]: { validator: function(val, name, context) { @@ -245,22 +244,22 @@ describe('State', function() { assert.strictEqual(state, context); done(); - } - } + }, + }, }); state[keyName] = value; }); it('should validate new state values', function() { - var state = new State(); + let state = new State(); state.configState({ key1: { validator: function(val) { return val > 0; }, - value: 1 - } + value: 1, + }, }); state.key1 = -1; @@ -271,15 +270,15 @@ describe('State', function() { }); it('should validate new state values through function name', function() { - var state = new State(); + let state = new State(); state.isPositive = function(val) { return val > 0; }; state.configState({ key1: { validator: 'isPositive', - value: 1 - } + value: 1, + }, }); state.key1 = -1; @@ -290,52 +289,48 @@ describe('State', function() { }); it('should validate initial state values', function() { - var state = new State({ - key1: -10 + let state = new State({ + key1: -10, + }); + state.configState({ + key1: { + validator: function(val) { + return val > 0; + }, + value: 1, + }, }); - state.configState( - { - key1: { - validator: function(val) { - return val > 0; - }, - value: 1 - } - } - ); assert.strictEqual(1, state.key1); }); it('should not overwrite default value with "undefined" initial value', function() { - var state = new State({ - key1: undefined + let state = new State({ + key1: undefined, }); state.configState({ key1: { - value: 'value1' - } + value: 'value1', + }, }); assert.equal(state.key1, 'value1'); }); it('should allow accessing other state properties in validator', function() { - var state = new State({ - key1: 1 + let state = new State({ + key1: 1, }); - state.configState( - { - key1: { - validator: function(val) { - return val < this.key2; - } + state.configState({ + key1: { + validator: function(val) { + return val < this.key2; }, - key2: { - value: 2 - } - } - ); + }, + key2: { + value: 2, + }, + }); assert.strictEqual(1, state.key1); state.key1 = 3; @@ -346,32 +341,30 @@ describe('State', function() { }); it('should not validate default state values', function() { - var state = new State(); + let state = new State(); state.configState({ key1: { validator: function(val) { return val > 0; }, - value: -1 - } + value: -1, + }, }); assert.strictEqual(-1, state.key1); }); it('should emit error if validator returns an Error', function() { - var originalConsoleFn = console.error; + let originalConsoleFn = console.error; console.error = sinon.stub(); - var state = new State(); - state.configState( - { - key1: { - validator: function(val) { - return val; - } - } - } - ); + let state = new State(); + state.configState({ + key1: { + validator: function(val) { + return val; + }, + }, + }); state.key1 = 1; assert.ok(!console.error.called); @@ -383,20 +376,19 @@ describe('State', function() { }); it('should emit validator error even for "undefined" initial values', function() { - var originalConsoleFn = console.error; + let originalConsoleFn = console.error; console.error = sinon.stub(); - class Test extends State { - } + class Test extends State {} Test.STATE = { key1: { validator: function() { return new Error(); - } - } + }, + }, }; new Test({ - key1: undefined + key1: undefined, }); assert.ok(console.error.called); @@ -409,18 +401,16 @@ describe('State', function() { return true; } } - var state = new Test(); - state.configState( - { - key1: { - validator: function() { - return new Error(); - } - } - } - ); + let state = new Test(); + state.configState({ + key1: { + validator: function() { + return new Error(); + }, + }, + }); - assert.throws(() => state.key1 = 1); + assert.throws(() => (state.key1 = 1)); }); it('should not throw error if validator returns an Error and shouldThrowValidationError is false', function() { @@ -429,28 +419,26 @@ describe('State', function() { return false; } } - var state = new Test(); - state.configState( - { - key1: { - validator: function() { - return new Error(); - } - } - } - ); + let state = new Test(); + state.configState({ + key1: { + validator: function() { + return new Error(); + }, + }, + }); - assert.doesNotThrow(() => state.key1 = 1); + assert.doesNotThrow(() => (state.key1 = 1)); assert.strictEqual(1, state.key1); }); it('should change state new value through setter', function() { - var state = new State(); + let state = new State(); state.configState({ key1: { setter: Math.abs, - value: -1 - } + value: -1, + }, }); assert.strictEqual(1, state.key1); @@ -463,13 +451,13 @@ describe('State', function() { }); it('should change state new value through setter name', function() { - var state = new State(); + let state = new State(); state.makePositive = Math.abs; state.configState({ key1: { setter: 'makePositive', - value: -1 - } + value: -1, + }, }); assert.strictEqual(1, state.key1); @@ -482,14 +470,14 @@ describe('State', function() { }); it('should pass the state key\'s current value to setter', function() { - var state = new State(); + let state = new State(); state.configState({ key1: { setter: (newValue, currentValue) => { return currentValue ? currentValue + ':' + newValue : newValue; }, - value: 'first' - } + value: 'first', + }, }); assert.strictEqual('first', state.key1); @@ -502,42 +490,39 @@ describe('State', function() { }); it('should allow setting a writeOnce with initial value', function() { - var state = new State({ - key1: 2 + let state = new State({ + key1: 2, + }); + state.configState({ + key1: { + value: 1, + writeOnce: true, + }, }); - state.configState( - { - key1: { - value: 1, - writeOnce: true - } - } - ); assert.strictEqual(2, state.key1); }); it('should allow setting a writeOnce state value before it has been written', function() { - var state = new State(); + let state = new State(); state.configState({ key1: { value: 1, - writeOnce: true - } + writeOnce: true, + }, }); state.key1 = 2; assert.strictEqual(2, state.key1); }); - it('should not allow changing a writeOnce state value after it has been written', function() { - var state = new State(); + let state = new State(); state.configState({ key1: { value: 1, - writeOnce: true - } + writeOnce: true, + }, }); assert.strictEqual(1, state.key1); @@ -558,40 +543,38 @@ describe('State', function() { }); it('should log error if required property gets no initial value via configState', function() { - var state = new State({ - key2: 'initialValue' + let state = new State({ + key2: 'initialValue', }); state.configState({ - key1: {} + key1: {}, }); assert.strictEqual(0, console.error.callCount); - state.configState( - { - key2: { - required: true - } - } - ); + state.configState({ + key2: { + required: true, + }, + }); assert.strictEqual(0, console.error.callCount); state.configState({ key3: { - required: true - } + required: true, + }, }); assert.strictEqual(1, console.error.callCount); }); it('should log error if required property is set to null or undefined', function() { - var state = new State({ - key: 'initialValue' + let state = new State({ + key: 'initialValue', }); state.configState({ key: { - required: true - } + required: true, + }, }); assert.strictEqual(0, console.error.callCount); @@ -611,31 +594,29 @@ describe('State', function() { return true; } } - var state = new Test({ - key2: 'initialValue' + let state = new Test({ + key2: 'initialValue', }); assert.doesNotThrow(() => { state.configState({ - key1: {} + key1: {}, }); }); assert.doesNotThrow(() => { - state.configState( - { - key2: { - required: true - } - } - ); + state.configState({ + key2: { + required: true, + }, + }); }); assert.throws(() => { state.configState({ key3: { - required: true - } + required: true, + }, }); }); }); @@ -646,15 +627,15 @@ describe('State', function() { return true; } } - var state = new Test({ - key: 'initialValue' + let state = new Test({ + key: 'initialValue', }); assert.doesNotThrow(() => { state.configState({ key: { - required: true - } + required: true, + }, }); }); @@ -679,8 +660,8 @@ describe('State', function() { } Test.STATE = { key: { - required: true - } + required: true, + }, }; assert.throws(() => { @@ -690,17 +671,17 @@ describe('State', function() { }); it('should emit event when a state key\'s value changes', function() { - var state = new State({ - key1: 10 + let state = new State({ + key1: 10, }); state.configState({ key1: { value: 1, - writeOnce: true - } + writeOnce: true, + }, }); - var listener = sinon.stub(); + let listener = sinon.stub(); state.on('key1Changed', listener); state.key1 = 2; @@ -713,17 +694,17 @@ describe('State', function() { }); it('should emit stateKeyChanged event when a state key\'s value changes', function() { - var state = new State({ - key1: 10 + let state = new State({ + key1: 10, }); state.configState({ key1: { value: 1, - writeOnce: true - } + writeOnce: true, + }, }); - var listener = sinon.stub(); + let listener = sinon.stub(); state.on('stateKeyChanged', listener); state.key1 = 2; @@ -736,8 +717,8 @@ describe('State', function() { }); it('should not emit events when state value doesn\'t change', function() { - var state = createStateInstance(); - var listener = sinon.stub(); + let state = createStateInstance(); + let listener = sinon.stub(); state.on('key1Changed', listener); state.key1 = state.key1; @@ -745,10 +726,10 @@ describe('State', function() { }); it('should emit events even when state value doesn\'t change if value is an object', function() { - var state = createStateInstance(); + let state = createStateInstance(); state.key1 = {}; - var listener = sinon.stub(); + let listener = sinon.stub(); state.on('key1Changed', listener); state.key1 = state.key1; @@ -756,10 +737,10 @@ describe('State', function() { }); it('should emit events even when state value doesn\'t change if value is an array', function() { - var state = createStateInstance(); + let state = createStateInstance(); state.key1 = []; - var listener = sinon.stub(); + let listener = sinon.stub(); state.on('key1Changed', listener); state.key1 = state.key1; @@ -767,24 +748,26 @@ describe('State', function() { }); it('should emit events even when state value doesn\'t change if value is a function', function() { - var state = createStateInstance(); + let state = createStateInstance(); state.key1 = function() {}; - var listener = sinon.stub(); + let listener = sinon.stub(); state.on('key1Changed', listener); state.key1 = state.key1; assert.strictEqual(1, listener.callCount); }); - it('should emit a preemptive batch event with all state changes for the cycle for providing a hook point', function(done) { - var state = createStateInstance(); + it('should emit a preemptive batch event with all state changes for the cycle for providing a hook point', function( + done + ) { + let state = createStateInstance(); - state.on('stateWillChange', function(data) { + state.on('stateWillChange', function() { state.key2 = 20; }); - state.on('stateChanged', function(data, facade) { + state.on('stateChanged', function(data) { assert.strictEqual(1, data.changes.key1.prevVal); assert.strictEqual(10, data.changes.key1.newVal); assert.strictEqual(2, data.changes.key2.prevVal); @@ -795,8 +778,10 @@ describe('State', function() { state.key1 = 10; }); - it('should emit a batch event with all state changes for the cycle', function(done) { - var state = createStateInstance(); + it('should emit a batch event with all state changes for the cycle', function( + done + ) { + let state = createStateInstance(); state.on('stateChanged', function(data, facade) { assert.strictEqual(2, Object.keys(data.changes).length); @@ -817,17 +802,17 @@ describe('State', function() { }); it('should pass given event data with change events', function() { - var state = new State({ - key1: 10 + let state = new State({ + key1: 10, }); state.configState({ - key1: {} + key1: {}, }); state.setEventData({ - foo: 'bar' + foo: 'bar', }); - var listener = sinon.stub(); + let listener = sinon.stub(); state.on('key1Changed', listener); state.key1 = 2; @@ -835,21 +820,23 @@ describe('State', function() { foo: 'bar', key: 'key1', newVal: 2, - prevVal: 10 + prevVal: 10, }; assert.strictEqual(1, listener.callCount); assert.deepEqual(expected, listener.args[0][0]); }); - it('should call callback function from setState asynchronously after the batch event is triggered', function(done) { - var state = createStateInstance(); + it('should call callback function from setState asynchronously after the batch event is triggered', function( + done + ) { + let state = createStateInstance(); - var listener = sinon.stub(); + let listener = sinon.stub(); state.on('stateChanged', listener); - var newState = { + let newState = { key1: 12, - key2: 21 + key2: 21, }; state.setState(newState, function() { assert.strictEqual(1, listener.callCount); @@ -858,31 +845,31 @@ describe('State', function() { }); it('should get all state values', function() { - var state = createStateInstance(); + let state = createStateInstance(); state.key1 = 10; - var stateObj = state.getState(); + let stateObj = state.getState(); assert.strictEqual(2, Object.keys(stateObj).length); assert.strictEqual(10, stateObj.key1); assert.strictEqual(2, stateObj.key2); }); it('should get values for the specified state keys', function() { - var state = createStateInstance(); + let state = createStateInstance(); state.key1 = 10; - var stateObj = state.getState(['key1']); + let stateObj = state.getState(['key1']); assert.strictEqual(1, Object.keys(stateObj).length); assert.strictEqual(10, stateObj.key1); }); it('should set all state values', function() { - var state = createStateInstance(); + let state = createStateInstance(); state.setState({ key1: 10, - key2: 20 + key2: 20, }); assert.strictEqual(10, state.key1); @@ -890,11 +877,11 @@ describe('State', function() { }); it('should not change properties that are not state keys via "setState"', function() { - var state = createStateInstance(); + let state = createStateInstance(); state.myVar = 1; state.setState({ key1: 10, - myVar: 2 + myVar: 2, }); assert.strictEqual(10, state.key1); @@ -902,12 +889,12 @@ describe('State', function() { }); it('should check if a state key\'s value has already been set', function() { - var state = new State({ - key1: 1 + let state = new State({ + key1: 1, }); state.configState({ key1: {}, - key2: {} + key2: {}, }); assert.ok(state.hasBeenSet('key1')); @@ -918,7 +905,7 @@ describe('State', function() { }); it('should not run setter, validator or events for removed state keys', function() { - var state = new State(); + let state = new State(); state.configState({ key1: { setter: function(val) { @@ -926,10 +913,10 @@ describe('State', function() { }, validator: function(val) { return val > 0; - } - } + }, + }, }); - var listener = sinon.stub(); + let listener = sinon.stub(); state.on('key1Changed', listener); state.removeStateKey('key1'); @@ -942,145 +929,141 @@ describe('State', function() { describe('Static STATE', function() { function createTestClass() { - class Test extends State { - } + class Test extends State {} return Test; } it('should automatically add state keys defined by STATE', function() { - var Test = createTestClass(); + let Test = createTestClass(); Test.STATE = { key1: { - value: 1 - } + value: 1, + }, }; - var test = new Test(); + let test = new Test(); assert.strictEqual(1, test.key1); }); it('should use config object from constructor to initialize state', function() { - var Test = createTestClass(); + let Test = createTestClass(); Test.STATE = { key1: { - value: 1 - } + value: 1, + }, }; - var test = new Test({ - key1: 2 + let test = new Test({ + key1: 2, }); assert.strictEqual(2, test.key1); }); it('should merge STATE from super class', function() { - var Test = createTestClass(); + let Test = createTestClass(); Test.STATE = { key1: { - value: 1 + value: 1, }, key2: { - value: 2 - } + value: 2, + }, }; - class ChildTest extends Test { - } + class ChildTest extends Test {} ChildTest.STATE = { key1: { - value: -1 + value: -1, }, key3: { - value: 3 - } + value: 3, + }, }; - var child = new ChildTest(); + let child = new ChildTest(); assert.strictEqual(-1, child.key1); assert.strictEqual(2, child.key2); assert.strictEqual(3, child.key3); - var test = new Test(); + let test = new Test(); assert.strictEqual(1, test.key1); assert.strictEqual(2, test.key2); assert.strictEqual(undefined, test.key3); }); it('should get STATE property value of given constructor', function() { - var Test = createTestClass(); + let Test = createTestClass(); Test.STATE = { key1: { - value: 1 + value: 1, }, key2: { - value: 2 - } + value: 2, + }, }; - class ChildTest extends Test { - } + class ChildTest extends Test {} ChildTest.STATE = { key1: { - value: -1 + value: -1, }, key3: { - value: 3 - } + value: 3, + }, }; - assert.deepEqual({ - key1: { - value: -1 - }, - key2: { - value: 2 + assert.deepEqual( + { + key1: { + value: -1, + }, + key2: { + value: 2, + }, + key3: { + value: 3, + }, }, - key3: { - value: 3 - } - }, State.getStateStatic(ChildTest)); + State.getStateStatic(ChildTest) + ); }); it('should conflict STATE properties from instance with previous instances', function() { - var Test = createTestClass(); + let Test = createTestClass(); Test.STATE = { - key1: { - } + key1: {}, }; - var test1 = new Test({ - key1: 'foo1' + let test1 = new Test({ + key1: 'foo1', }); assert.strictEqual('foo1', test1.key1); - var test2 = new Test({ - key1: 'foo2' + let test2 = new Test({ + key1: 'foo2', }); assert.strictEqual('foo2', test2.key1); assert.strictEqual('foo1', test1.key1); }); it('should configure static STATE with multiple levels of class inheritance', function() { - var Test = createTestClass(); + let Test = createTestClass(); Test.STATE = { - key1: { - } + key1: {}, }; - class Child extends Test { - } + class Child extends Test {} Child.STATE = { - key2: { - } + key2: {}, }; - var test = new Test({ - key1: 'foo1' + let test = new Test({ + key1: 'foo1', }); assert.strictEqual('foo1', test.key1); - var child = new Child({ - key2: 'foo2' + let child = new Child({ + key2: 'foo2', }); assert.strictEqual('foo1', test.key1); assert.strictEqual('foo2', child.key2); @@ -1089,28 +1072,27 @@ describe('State', function() { describe('Separate object', function() { it('should add state properties to given object', function() { - var obj = {}; - var state = new State({}, obj); + let obj = {}; + let state = new State({}, obj); state.configState({ key1: {}, - key2: {} + key2: {}, }); - var keys = Object.keys(obj); + let keys = Object.keys(obj); assert.strictEqual(2, keys.length); assert.deepEqual(['key1', 'key2'], keys.sort()); }); it('should add state properties from STATE static variable to object under given name', function() { - class Test extends State { - } + class Test extends State {} Test.STATE = { key1: { - value: 1 - } + value: 1, + }, }; - var obj = {}; + let obj = {}; new Test({}, obj); assert.strictEqual(1, obj.key1); }); @@ -1125,29 +1107,26 @@ describe('State', function() { Test.STATE = { key1: { setter: 'setFn', - value: 1 - } + value: 1, + }, }; - var obj = { + let obj = { setFn(val) { return 'obj:' + val; - } + }, }; new Test({}, obj, obj); assert.strictEqual('obj:1', obj.key1); }); it('should use given context object when emitting change events', function() { - class Test extends State { - } + class Test extends State {} Test.STATE = { - key1: { - } + key1: {}, }; - class Test2 extends EventEmitter { - } + class Test2 extends EventEmitter {} const obj = new Test2(); const listener = sinon.stub(); obj.on('key1Changed', listener); @@ -1161,27 +1140,30 @@ describe('State', function() { const expected = { key: 'key1', newVal: 2, - prevVal: undefined + prevVal: undefined, }; assert.deepEqual(expected, listener.args[0][0]); }); it('should pass given context object when calling validator', function() { - var validator = sinon.stub().returns(true); - class Test extends State { - } + let validator = sinon.stub().returns(true); + class Test extends State {} Test.STATE = { key1: { - validator - } + validator, + }, }; - var obj = {}; - var context = {}; - var key1 = 1; - new Test({ - key1 - }, obj, context); + let obj = {}; + let context = {}; + let key1 = 1; + new Test( + { + key1, + }, + obj, + context + ); assert.strictEqual(1, obj.key1); assert.strictEqual(1, validator.callCount); assert.strictEqual(1, validator.args[0][0]); @@ -1190,26 +1172,26 @@ describe('State', function() { }); it('should remove state properties from object under given name', function() { - var obj = {}; - var state = new State({}, obj); + let obj = {}; + let state = new State({}, obj); state.configState({ key1: {}, - key2: {} + key2: {}, }); state.removeStateKey('key1'); - var keys = Object.keys(obj); + let keys = Object.keys(obj); assert.strictEqual(1, keys.length); assert.deepEqual('key2', keys[0]); }); it('should create new object with same state properties when getState is called', function() { - var obj = {}; - var state = new State({}, obj); + let obj = {}; + let state = new State({}, obj); state.configState({ key1: {}, - key2: {} + key2: {}, }); assert.deepEqual(obj, state.getState()); @@ -1217,14 +1199,14 @@ describe('State', function() { }); it('should emit event when state property changes', function() { - var obj = {}; - var state = new State({}, obj); + let obj = {}; + let state = new State({}, obj); state.configState({ key1: {}, - key2: {} + key2: {}, }); - var listener = sinon.stub(); + let listener = sinon.stub(); state.on('key1Changed', listener); obj.key1 = 'newVal'; @@ -1252,8 +1234,10 @@ describe('State', function() { console.warn = originalWarnFn; }); - it('should not throw error when trying to emit scheduled stateChanged after disposed', function(done) { - var state = createStateInstance(); + it('should not throw error when trying to emit scheduled stateChanged after disposed', function( + done + ) { + let state = createStateInstance(); state.key1 = 10; state.dispose(); @@ -1263,38 +1247,38 @@ describe('State', function() { }); it('should warn if trying to get state property after disposed', function() { - var state = createStateInstance(); + let state = createStateInstance(); state.dispose(); assert.doesNotThrow(() => state.key1); assert.strictEqual(1, console.warn.callCount); }); it('should warn if trying to set state property after disposed', function() { - var state = createStateInstance(); + let state = createStateInstance(); state.dispose(); - assert.doesNotThrow(() => state.key1 = 'new'); + assert.doesNotThrow(() => (state.key1 = 'new')); assert.strictEqual(1, console.warn.callCount); }); it('should warn if trying to use "setState" after disposed', function() { - var state = createStateInstance(); + let state = createStateInstance(); state.dispose(); assert.doesNotThrow(() => { state.setState({ - key1: 'new' + key1: 'new', }); }); assert.strictEqual(1, console.warn.callCount); }); it('should not throw error if trying to use "getState" after disposed', function() { - var state = createStateInstance(); + let state = createStateInstance(); state.dispose(); assert.doesNotThrow(() => state.getState()); }); it('should not throw error if trying to use "getStateKeyConfig" after disposed', function() { - var state = createStateInstance(); + let state = createStateInstance(); state.dispose(); assert.doesNotThrow(() => state.getStateKeyConfig()); }); @@ -1302,14 +1286,14 @@ describe('State', function() { }); function createStateInstance() { - var state = new State(); + let state = new State(); state.configState({ key1: { - value: 1 + value: 1, }, key2: { - value: 2 - } + value: 2, + }, }); return state; diff --git a/packages/metal-state/test/validators.js b/packages/metal-state/test/validators.js index 7c8aec14..be251dca 100644 --- a/packages/metal-state/test/validators.js +++ b/packages/metal-state/test/validators.js @@ -66,10 +66,8 @@ describe('validators', function() { }); it('should validate an instance of a class', function() { - class TestClass { - } - class TestClass2 { - } + class TestClass {} + class TestClass2 {} const instanceOfFn = validators.instanceOf(TestClass); @@ -91,12 +89,7 @@ describe('validators', function() { }); it('should validate equality against an array of values', function() { - const validator = validators.oneOf( - [ - 'one', - 1 - ] - ); + const validator = validators.oneOf(['one', 1]); assert.isTrue(validator('one')); assert.isTrue(validator(1)); @@ -110,12 +103,10 @@ describe('validators', function() { }); it('should validate one of certain types', function() { - const oneOfType = validators.oneOfType( - [ - validators.string, - validators.number - ] - ); + const oneOfType = validators.oneOfType([ + validators.string, + validators.number, + ]); assert.isTrue(oneOfType('test')); @@ -125,11 +116,9 @@ describe('validators', function() { }); it('should fail if an array is not supplied to oneOfType', function() { - const validator = validators.oneOfType( - { - one: validators.string - } - ); + const validator = validators.oneOfType({ + one: validators.string, + }); assert.ok(validator({}) instanceof Error); }); @@ -137,32 +126,40 @@ describe('validators', function() { it('should validate an object with certain types of values', function() { const objectOf = validators.objectOf(validators.number); - assert.isTrue(objectOf({ - a: 1, - b: 2 - })); + assert.isTrue( + objectOf({ + a: 1, + b: 2, + }) + ); - assert.ok(objectOf({ + assert.ok( + objectOf({ a: '1', - b: '2' - }) instanceof Error); + b: '2', + }) instanceof Error + ); }); it('should validate a shape of an object', function() { const shape = validators.shapeOf({ a: validators.string, - b: validators.number + b: validators.number, }); - assert.isTrue(shape({ - a: '1', - b: 2 - })); + assert.isTrue( + shape({ + a: '1', + b: 2, + }) + ); - assert.ok(shape({ + assert.ok( + shape({ a: '1', - b: '2' - }) instanceof Error); + b: '2', + }) instanceof Error + ); }); it('should validate a shape nested within a shape', function() { @@ -171,31 +168,37 @@ describe('validators', function() { b: { config: { required: true, - validator: validators.string - } - } - }) + validator: validators.string, + }, + }, + }), }); - assert.isTrue(shape({ - a: { - b: 'test' - } - })); + assert.isTrue( + shape({ + a: { + b: 'test', + }, + }) + ); - assert.ok(shape({ + assert.ok( + shape({ a: { - b: 1 - } - }) instanceof Error); + b: 1, + }, + }) instanceof Error + ); - assert.ok(shape({ - a: 1 - }) instanceof Error); + assert.ok( + shape({ + a: 1, + }) instanceof Error + ); }); it('should return validator function instead of running it if no arg is passed to type validator', function() { - var validatorFn = validators.bool(); + let validatorFn = validators.bool(); assert.isTrue(core.isFunction(validatorFn)); assert.isTrue(validatorFn(true)); assert.ok(validatorFn('true') instanceof Error); @@ -211,7 +214,8 @@ describe('validators', function() { const NAME = 'name'; const PARENT_COMPONENT_NAME = 'parentComponent'; - const ERROR_MESSAGE = `Error: Warning: Invalid state passed to '${NAME}'. ` + + const ERROR_MESSAGE = + `Error: Warning: Invalid state passed to '${NAME}'. ` + `Expected type 'string', but received type 'number'. ` + `Passed to '${COMPONENT_NAME}'. Check render ` + `method of '${PARENT_COMPONENT_NAME}'.`; @@ -222,15 +226,15 @@ describe('validators', function() { getParent: () => { return { constructor: { - name: PARENT_COMPONENT_NAME - } + name: PARENT_COMPONENT_NAME, + }, }; - } + }, }; }, constructor: { - name: COMPONENT_NAME - } + name: COMPONENT_NAME, + }, }; const resultError = validators.string(1, NAME, context); diff --git a/packages/metal-web-component/package-lock.json b/packages/metal-web-component/package-lock.json index 65ab2703..e9918c21 100644 --- a/packages/metal-web-component/package-lock.json +++ b/packages/metal-web-component/package-lock.json @@ -3,7 +3,7 @@ "lockfileVersion": 1, "dependencies": { "@webcomponents/webcomponentsjs": { - "version": "github:webcomponents/webcomponentsjs#eb9edd87fb7662ff56aef786b8cd5e229d3342fb" + "version": "github:webcomponents/webcomponentsjs#1913eb6cf975a598fc04cd8a4371f787b4a32088" }, "ansi-regex": { "version": "2.1.1", @@ -67,7 +67,7 @@ "lodash": "4.17.4", "minimatch": "3.0.4", "path-is-absolute": "1.0.1", - "private": "0.1.7", + "private": "0.1.8", "slash": "1.0.0", "source-map": "0.5.7" } @@ -510,9 +510,9 @@ } }, "babel-preset-env": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/babel-preset-env/-/babel-preset-env-1.6.0.tgz", - "integrity": "sha512-OVgtQRuOZKckrILgMA5rvctvFZPv72Gua9Rt006AiPoB0DJKGN07UmaQA+qRrYgK71MVct8fFhT0EyNWYorVew==", + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/babel-preset-env/-/babel-preset-env-1.6.1.tgz", + "integrity": "sha512-W6VIyA6Ch9ePMI7VptNn2wBM6dbG0eSz25HEiL40nQXCsXGTGZSTZu1Iap+cj3Q0S5a7T9+529l/5Bkvd+afNA==", "requires": { "babel-plugin-check-es2015-constants": "6.22.0", "babel-plugin-syntax-trailing-function-commas": "6.22.0", @@ -541,7 +541,7 @@ "babel-plugin-transform-es2015-unicode-regex": "6.24.1", "babel-plugin-transform-exponentiation-operator": "6.24.1", "babel-plugin-transform-regenerator": "6.26.0", - "browserslist": "2.5.1", + "browserslist": "2.8.0", "invariant": "2.2.2", "semver": "5.4.1" } @@ -628,18 +628,18 @@ } }, "browserslist": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-2.5.1.tgz", - "integrity": "sha512-jAvM2ku7YDJ+leAq3bFH1DE0Ylw+F+EQDq4GkqZfgPEqpWYw9ofQH85uKSB9r3Tv7XDbfqVtE+sdvKJW7IlPJA==", + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-2.8.0.tgz", + "integrity": "sha512-iiWHM1Et6Q4TQpB7Ar6pxuM3TNMXasVJY4Y/oh3q38EwR3Z+IdZ9MyVf7PI4MJFB4xpwMcZgs9bEUnPG2E3TCA==", "requires": { - "caniuse-lite": "1.0.30000746", - "electron-to-chromium": "1.3.25" + "caniuse-lite": "1.0.30000760", + "electron-to-chromium": "1.3.27" } }, "caniuse-lite": { - "version": "1.0.30000746", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000746.tgz", - "integrity": "sha1-xk+Vo5Jc/TAgejCO12wa6W6gnqA=" + "version": "1.0.30000760", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000760.tgz", + "integrity": "sha1-7HIDlXQvHH7IlH/W3SYE53qPmP8=" }, "chalk": { "version": "1.1.3", @@ -690,9 +690,9 @@ } }, "electron-to-chromium": { - "version": "1.3.25", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.25.tgz", - "integrity": "sha1-RTshAJg20Jl9hgNWAf9srkeRxGA=" + "version": "1.3.27", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.27.tgz", + "integrity": "sha1-eOy4o5kGYYe7N07t412ccFZagD0=" }, "escape-string-regexp": { "version": "1.0.5", @@ -813,16 +813,16 @@ } }, "metal": { - "version": "2.13.2", - "resolved": "https://registry.npmjs.org/metal/-/metal-2.13.2.tgz", - "integrity": "sha512-DqETxwvyW5I/3blSlxrr1eleLaLHItK1VJcGIL6hAVqSlUpYw0r+RXd8qWfIq6TMdjCU3/x/oGmWZyk+O4SZJw==" + "version": "2.14.0", + "resolved": "https://registry.npmjs.org/metal/-/metal-2.14.0.tgz", + "integrity": "sha512-dk4MUJZ5Rj+sB9RgZcATU8QRDxHKPn85ymVWC+PamDhcIEYsY5Fg+I6vOQ1Bo4J+54z/k9KF2K7fmUIRtoRb+w==" }, "metal-events": { - "version": "2.13.2", - "resolved": "https://registry.npmjs.org/metal-events/-/metal-events-2.13.2.tgz", - "integrity": "sha512-iEuqr5+T87Bq114wV/okNzwS25i/c4jqmIZ6IBLPFTD1Gxbk6qEiklnWf7Z2iVbqPYOz+2LgL130Nt2U4eb9tA==", + "version": "2.14.0", + "resolved": "https://registry.npmjs.org/metal-events/-/metal-events-2.14.0.tgz", + "integrity": "sha512-LKV9EOMRzM1Sb5BD4Hfcy7aaepCCRrDVbMOq9O48KuGXawKG4XTZcLhR6J1dFI3UzF+BeO11Kh1v+4DxUAH1CA==", "requires": { - "metal": "2.13.2" + "metal": "2.14.0" } }, "metal-state": { @@ -830,8 +830,8 @@ "resolved": "https://registry.npmjs.org/metal-state/-/metal-state-2.7.0.tgz", "integrity": "sha1-VWis04wc2O/Mr7kAiWDVCN9/olI=", "requires": { - "metal": "2.13.2", - "metal-events": "2.13.2" + "metal": "2.14.0", + "metal-events": "2.14.0" } }, "metal-useragent": { @@ -839,7 +839,7 @@ "resolved": "https://registry.npmjs.org/metal-useragent/-/metal-useragent-2.1.3.tgz", "integrity": "sha1-9Yfb1hPE18kFBjn1iXMSdThjcWk=", "requires": { - "metal": "2.13.2" + "metal": "2.14.0" } }, "minimatch": { @@ -912,9 +912,9 @@ "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" }, "private": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/private/-/private-0.1.7.tgz", - "integrity": "sha1-aM5eih7woju1cMwoU3tTMqumPvE=" + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/private/-/private-0.1.8.tgz", + "integrity": "sha512-VvivMrbvd2nKkiG38qjULzlc+4Vx4wm/whI9pQD35YrARNnhxeiRktSOhSukRLFNlzg6Br/cJPet5J/u19r/mg==" }, "regenerate": { "version": "1.3.3", @@ -933,7 +933,7 @@ "requires": { "babel-runtime": "6.26.0", "babel-types": "6.26.0", - "private": "0.1.7" + "private": "0.1.8" } }, "regexpu-core": { diff --git a/packages/metal-web-component/src/define_web_component.js b/packages/metal-web-component/src/define_web_component.js index 1746724d..93bf10c3 100644 --- a/packages/metal-web-component/src/define_web_component.js +++ b/packages/metal-web-component/src/define_web_component.js @@ -1,5 +1,5 @@ -import State, { mergeState } from 'metal-state'; -import { getStaticProperty, isObject } from 'metal'; +import State, {mergeState} from 'metal-state'; +import {getStaticProperty, isObject} from 'metal'; /** * Register a custom element for a given Metal component. @@ -74,7 +74,7 @@ export function defineWebComponent(tagName, Ctor) { if (useShadowDOM) { element = this.attachShadow({ - mode: 'open' + mode: 'open', }); } @@ -96,6 +96,7 @@ export function defineWebComponent(tagName, Ctor) { * * @memberof CustomElement * @param {?} value attribute value that should be parsed. + * @return {Object} */ deserializeValue_: function(value) { let retVal; @@ -128,13 +129,13 @@ export function defineWebComponent(tagName, Ctor) { emit: function(...data) { const eventData = data.pop(); const event = new CustomEvent(eventData.type, { - detail: data + detail: data, }); this.dispatchEvent(event); - } + }, }); window.customElements.define(tagName, CustomElement); -}; +} export default defineWebComponent; diff --git a/packages/metal-web-component/test/.eslintrc b/packages/metal-web-component/test/.eslintrc new file mode 100644 index 00000000..1547409b --- /dev/null +++ b/packages/metal-web-component/test/.eslintrc @@ -0,0 +1,16 @@ +{ + "env": { + "mocha": true + }, + "globals": { + "assert": true, + "before": true, + "IncrementalDOM": true, + "sinon": true + }, + "rules": { + "max-len": 0, + "no-invalid-this": 0, + "require-jsdoc": 0 + } +} \ No newline at end of file diff --git a/packages/metal-web-component/test/.eslintrc.json b/packages/metal-web-component/test/.eslintrc.json deleted file mode 100644 index f361917d..00000000 --- a/packages/metal-web-component/test/.eslintrc.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "env": { - "mocha": true - }, - "globals": { - "assert": true, - "sinon": true, - "IncrementalDOM": true - } -} diff --git a/packages/metal-web-component/test/define_web_component.js b/packages/metal-web-component/test/define_web_component.js index 17e5c008..b1f9dce8 100644 --- a/packages/metal-web-component/test/define_web_component.js +++ b/packages/metal-web-component/test/define_web_component.js @@ -3,9 +3,9 @@ import Component from 'metal-component'; import Soy from 'metal-soy'; import UA from 'metal-useragent'; -import { JSXComponent } from 'metal-jsx'; +import {JSXComponent} from 'metal-jsx'; -import { defineWebComponent } from '../src/define_web_component'; +import {defineWebComponent} from '../src/define_web_component'; describe('Web components', function() { let el; @@ -81,7 +81,10 @@ describe('Web components', function() { document.body.appendChild(el); - assert.equal(el.shadowRoot.innerHTML, '
'); + assert.equal( + el.shadowRoot.innerHTML, + '
' + ); }); it('should render custom element via html', function() { @@ -91,19 +94,26 @@ describe('Web components', function() { document.body.innerHTML = innerHTML; - assert.equal(document.body.innerHTML, '
'); + assert.equal( + document.body.innerHTML, + '
' + ); }); it('should render custom element via html when useshadowdom is true', function() { const tagName = createWebComponent('custom-test-element-07'); - const innerHTML = '<' + tagName + ' useshadowdom="true">'; + const innerHTML = + '<' + tagName + ' useshadowdom="true">'; document.body.innerHTML = innerHTML; el = document.querySelector(tagName); - assert.equal(el.shadowRoot.innerHTML, '
'); + assert.equal( + el.shadowRoot.innerHTML, + '
' + ); }); it('should deserialize attribute if json is passed', function() { @@ -186,7 +196,10 @@ describe('Web components', function() { document.body.appendChild(el); - assert.equal(el.shadowRoot.innerHTML, '
'); + assert.equal( + el.shadowRoot.innerHTML, + '
' + ); }); it('should render custom element via html', function() { @@ -196,19 +209,26 @@ describe('Web components', function() { document.body.innerHTML = innerHTML; - assert.equal(document.body.innerHTML, '
'); + assert.equal( + document.body.innerHTML, + '
' + ); }); it('should render custom element via html when useshadowdom is true', function() { const tagName = createJSXWebComponent('custom-jsx-test-element-07'); - const innerHTML = '<' + tagName + ' useshadowdom="true">'; + const innerHTML = + '<' + tagName + ' useshadowdom="true">'; document.body.innerHTML = innerHTML; el = document.querySelector(tagName); - assert.equal(el.shadowRoot.innerHTML, '
'); + assert.equal( + el.shadowRoot.innerHTML, + '
' + ); }); it('should deserialize attribute if json is passed', function() { @@ -240,15 +260,16 @@ describe('Web components', function() { class WebComponent extends JSXComponent { render() { IncrementalDOM.elementVoid('div', null, [ - 'title', WebComponent.PROPS.title.value + 'title', + WebComponent.PROPS.title.value, ]); } } WebComponent.PROPS = { title: { - value: 'default title' - } + value: 'default title', + }, }; defineWebComponent(tagName, WebComponent); @@ -263,16 +284,17 @@ describe('Web components', function() { WebComponent.STATE = { title: { - value: 'default title' - } + value: 'default title', + }, }; Soy.register(WebComponent, { render: () => { IncrementalDOM.elementVoid('div', null, [ - 'title', WebComponent.STATE.title.value + 'title', + WebComponent.STATE.title.value, ]); - } + }, }); defineWebComponent(tagName, WebComponent); @@ -282,7 +304,7 @@ describe('Web components', function() { function isSafariVersion(version) { if (!UA.isSafari) return false; - const nav = window && window.navigator || {}; - return !!(new RegExp('Version\/' + version).exec(nav.userAgent)); + const nav = (window && window.navigator) || {}; + return !!new RegExp('Version/' + version).exec(nav.userAgent); } }); diff --git a/packages/metal-web-component/webcomponents_polyfill.js b/packages/metal-web-component/webcomponents_polyfill.js index bd913f72..da674a5e 100644 --- a/packages/metal-web-component/webcomponents_polyfill.js +++ b/packages/metal-web-component/webcomponents_polyfill.js @@ -1,9 +1,11 @@ +/* eslint no-var: 0 */ if (window.navigator.userAgent.indexOf('MSIE') === -1) { var script = document.createElement('script'); script.crossOrigin = 'anonymous'; - script.src = '/base/packages/metal-web-component/node_modules/@webcomponents/webcomponentsjs/webcomponents-lite.js'; + script.src = + '/base/packages/metal-web-component/node_modules/@webcomponents/webcomponentsjs/webcomponents-lite.js'; script.type = 'text/javascript'; document.body.appendChild(script); -} \ No newline at end of file +} diff --git a/packages/metal/package-lock.json b/packages/metal/package-lock.json index f9c637f5..7e4c66d6 100644 --- a/packages/metal/package-lock.json +++ b/packages/metal/package-lock.json @@ -64,7 +64,7 @@ "lodash": "4.17.4", "minimatch": "3.0.4", "path-is-absolute": "1.0.1", - "private": "0.1.7", + "private": "0.1.8", "slash": "1.0.0", "source-map": "0.5.7" } @@ -507,9 +507,9 @@ } }, "babel-preset-env": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/babel-preset-env/-/babel-preset-env-1.6.0.tgz", - "integrity": "sha512-OVgtQRuOZKckrILgMA5rvctvFZPv72Gua9Rt006AiPoB0DJKGN07UmaQA+qRrYgK71MVct8fFhT0EyNWYorVew==", + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/babel-preset-env/-/babel-preset-env-1.6.1.tgz", + "integrity": "sha512-W6VIyA6Ch9ePMI7VptNn2wBM6dbG0eSz25HEiL40nQXCsXGTGZSTZu1Iap+cj3Q0S5a7T9+529l/5Bkvd+afNA==", "requires": { "babel-plugin-check-es2015-constants": "6.22.0", "babel-plugin-syntax-trailing-function-commas": "6.22.0", @@ -538,7 +538,7 @@ "babel-plugin-transform-es2015-unicode-regex": "6.24.1", "babel-plugin-transform-exponentiation-operator": "6.24.1", "babel-plugin-transform-regenerator": "6.26.0", - "browserslist": "2.5.1", + "browserslist": "2.8.0", "invariant": "2.2.2", "semver": "5.4.1" } @@ -625,18 +625,18 @@ } }, "browserslist": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-2.5.1.tgz", - "integrity": "sha512-jAvM2ku7YDJ+leAq3bFH1DE0Ylw+F+EQDq4GkqZfgPEqpWYw9ofQH85uKSB9r3Tv7XDbfqVtE+sdvKJW7IlPJA==", + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-2.8.0.tgz", + "integrity": "sha512-iiWHM1Et6Q4TQpB7Ar6pxuM3TNMXasVJY4Y/oh3q38EwR3Z+IdZ9MyVf7PI4MJFB4xpwMcZgs9bEUnPG2E3TCA==", "requires": { - "caniuse-lite": "1.0.30000746", - "electron-to-chromium": "1.3.25" + "caniuse-lite": "1.0.30000760", + "electron-to-chromium": "1.3.27" } }, "caniuse-lite": { - "version": "1.0.30000746", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000746.tgz", - "integrity": "sha1-xk+Vo5Jc/TAgejCO12wa6W6gnqA=" + "version": "1.0.30000760", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000760.tgz", + "integrity": "sha1-7HIDlXQvHH7IlH/W3SYE53qPmP8=" }, "chalk": { "version": "1.1.3", @@ -687,9 +687,9 @@ } }, "electron-to-chromium": { - "version": "1.3.25", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.25.tgz", - "integrity": "sha1-RTshAJg20Jl9hgNWAf9srkeRxGA=" + "version": "1.3.27", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.27.tgz", + "integrity": "sha1-eOy4o5kGYYe7N07t412ccFZagD0=" }, "escape-string-regexp": { "version": "1.0.5", @@ -879,9 +879,9 @@ "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" }, "private": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/private/-/private-0.1.7.tgz", - "integrity": "sha1-aM5eih7woju1cMwoU3tTMqumPvE=" + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/private/-/private-0.1.8.tgz", + "integrity": "sha512-VvivMrbvd2nKkiG38qjULzlc+4Vx4wm/whI9pQD35YrARNnhxeiRktSOhSukRLFNlzg6Br/cJPet5J/u19r/mg==" }, "regenerate": { "version": "1.3.3", @@ -900,7 +900,7 @@ "requires": { "babel-runtime": "6.26.0", "babel-types": "6.26.0", - "private": "0.1.7" + "private": "0.1.8" } }, "regexpu-core": { diff --git a/packages/metal/src/array/array.js b/packages/metal/src/array/array.js index 3ae0872c..b12fdad9 100644 --- a/packages/metal/src/array/array.js +++ b/packages/metal/src/array/array.js @@ -1,7 +1,8 @@ 'use strict'; -import { isDef } from '../core'; - +/** + * Set of utilities for array operations + */ class array { /** * Checks if the given arrays have the same content. @@ -40,11 +41,10 @@ class array { /** * Transforms the input nested array to become flat. * @param {Array.<*|Array.<*>>} arr Nested array to flatten. - * @param {Array.<*>} opt_output Optional output array. + * @param {Array.<*>=} output Optional output array. * @return {Array.<*>} Flat array. */ - static flatten(arr, opt_output) { - var output = opt_output || []; + static flatten(arr, output = []) { for (let i = 0; i < arr.length; i++) { if (Array.isArray(arr[i])) { array.flatten(arr[i], output); @@ -65,7 +65,7 @@ class array { static remove(arr, obj) { const i = arr.indexOf(obj); let rv; - if ( (rv = i >= 0) ) { + if ((rv = i >= 0)) { array.removeAt(arr, i); } return rv; @@ -86,14 +86,13 @@ class array { * is faster and working on all array-like objects (like arguments). * @param {!Object} arr Array-like object to slice. * @param {number} start The index that should start the slice. - * @param {number=} opt_end The index where the slice should end, not + * @param {number=} end The index where the slice should end, not * included in the final array. If not given, all elements after the * start index will be included. * @return {!Array} */ - static slice(arr, start, opt_end) { + static slice(arr, start, end = arr.length) { const sliced = []; - const end = isDef(opt_end) ? opt_end : arr.length; for (let i = start; i < end; i++) { sliced.push(arr[i]); } diff --git a/packages/metal/src/async/async.js b/packages/metal/src/async/async.js index 51cb48b2..dd006052 100644 --- a/packages/metal/src/async/async.js +++ b/packages/metal/src/async/async.js @@ -1,4 +1,4 @@ -/*! +/* ! * Polyfill from Google's Closure Library. * Copyright 2013 The Closure Library Authors. All Rights Reserved. */ @@ -7,7 +7,6 @@ const async = {}; - /** * Throw an item without interrupting the current execution context. For * example, if processing a group of items in a loop, sometimes it is useful @@ -22,31 +21,27 @@ async.throwException = function(exception) { }); }; - /** * Fires the provided callback just before the current callstack unwinds, or as * soon as possible after the current JS execution context. * @param {function(this:THIS)} callback - * @param {THIS=} opt_context Object to use as the "this value" when calling + * @param {THIS=} context Object to use as the "this value" when calling * the provided function. * @template THIS */ -async.run = function(callback, opt_context) { +async.run = function(callback, context) { if (!async.run.workQueueScheduled_) { // Nothing is currently scheduled, schedule it now. async.nextTick(async.run.processWorkQueue); async.run.workQueueScheduled_ = true; } - async.run.workQueue_.push( - new async.run.WorkItem_(callback, opt_context)); + async.run.workQueue_.push(new async.run.WorkItem_(callback, context)); }; - /** @private {boolean} */ async.run.workQueueScheduled_ = false; - /** @private {!Array.} */ async.run.workQueue_ = []; @@ -75,7 +70,6 @@ async.run.processWorkQueue = function() { async.run.workQueueScheduled_ = false; }; - /** * @constructor * @final @@ -92,20 +86,19 @@ async.run.WorkItem_ = function(fn, scope) { this.scope = scope; }; - /** * Fires the provided callbacks as soon as possible after the current JS * execution context. setTimeout(…, 0) always takes at least 5ms for legacy * reasons. * @param {function(this:SCOPE)} callback Callback function to fire as soon as * possible. - * @param {SCOPE=} opt_context Object in whose scope to call the listener. + * @param {SCOPE=} context Object in whose scope to call the listener. * @template SCOPE */ -async.nextTick = function(callback, opt_context) { +async.nextTick = function(callback, context) { let cb = callback; - if (opt_context) { - cb = callback.bind(opt_context); + if (context) { + cb = callback.bind(context); } cb = async.nextTick.wrapCallback_(cb); // Introduced and currently only supported by IE10. @@ -119,12 +112,12 @@ async.nextTick = function(callback, opt_context) { } // Look for and cache the custom fallback version of setImmediate. if (!async.nextTick.setImmediate_) { + // eslint-disable-next-line async.nextTick.setImmediate_ = async.nextTick.getSetImmediateEmulator_(); } async.nextTick.setImmediate_(cb); }; - /** * Cache for the setImmediate implementation. * @type {function(function())} @@ -132,7 +125,6 @@ async.nextTick = function(callback, opt_context) { */ async.nextTick.setImmediate_ = null; - /** * Determines the best possible implementation to run a function as soon as * the JS event loop is idle. @@ -156,8 +148,12 @@ async.nextTick.getSetImmediateEmulator_ = function() { // an iframe based polyfill in browsers that have postMessage and // document.addEventListener. The latter excludes IE8 because it has a // synchronous postMessage implementation. - if (typeof Channel === 'undefined' && typeof window !== 'undefined' && - window.postMessage && window.addEventListener) { + if ( + typeof Channel === 'undefined' && + typeof window !== 'undefined' && + window.postMessage && + window.addEventListener + ) { /** @constructor */ Channel = function() { // Make an empty, invisible iframe. @@ -185,7 +181,7 @@ async.nextTick.getSetImmediateEmulator_ = function() { this.port2 = { postMessage: function() { win.postMessage(message, origin); - } + }, }; }; } @@ -202,7 +198,7 @@ async.nextTick.getSetImmediateEmulator_ = function() { }; return function(cb) { tail.next = { - cb: cb + cb: cb, }; tail = tail.next; channel.port2.postMessage(0); @@ -210,8 +206,10 @@ async.nextTick.getSetImmediateEmulator_ = function() { } // Implementation for IE6-8: Script elements fire an asynchronous // onreadystatechange event when inserted into the DOM. - if (typeof document !== 'undefined' && 'onreadystatechange' in - document.createElement('script')) { + if ( + typeof document !== 'undefined' && + 'onreadystatechange' in document.createElement('script') + ) { return function(cb) { let script = document.createElement('script'); script.onreadystatechange = function() { @@ -232,7 +230,6 @@ async.nextTick.getSetImmediateEmulator_ = function() { }; }; - /** * Helper function that is overrided to protect callbacks with entry point * monitor if the application monitors entry points. @@ -240,8 +237,8 @@ async.nextTick.getSetImmediateEmulator_ = function() { * @return {function()} The wrapped callback. * @private */ -async.nextTick.wrapCallback_ = function(opt_returnValue) { - return opt_returnValue; +async.nextTick.wrapCallback_ = function(callback) { + return callback; }; export default async; diff --git a/packages/metal/src/core.js b/packages/metal/src/core.js index 4ab49ecc..52118e70 100644 --- a/packages/metal/src/core.js +++ b/packages/metal/src/core.js @@ -7,5 +7,5 @@ import * as core from './coreNamed'; export default core; -export { core }; +export {core}; export * from './coreNamed'; diff --git a/packages/metal/src/coreNamed.js b/packages/metal/src/coreNamed.js index 34e94919..0dbfd127 100644 --- a/packages/metal/src/coreNamed.js +++ b/packages/metal/src/coreNamed.js @@ -19,7 +19,7 @@ let uniqueIdCounter_ = 1; * @type {String} * @protected */ -export const UID_PROPERTY = `core_${((Math.random() * 1e9) >>> 0)}`; +export const UID_PROPERTY = `core_${(Math.random() * 1e9) >>> 0}`; /** * When defining a class Foo with an abstract method bar(), you can do: @@ -50,7 +50,7 @@ export function disableCompatibilityMode() { * using "key" to keep working like before. NOTE: this may cause * problems, since "key" is meant to be used differently. Only use this * if it's not possible to upgrade the code to use "ref" instead. - * @param {Object=} opt_data Optional object with data to specify more + * @param {Object=} data Optional object with data to specify more * details, such as: * - renderers {Array} the template renderers that should be in * compatibility mode, either their constructors or strings @@ -58,8 +58,8 @@ export function disableCompatibilityMode() { * that extend from IncrementalDomRenderer. * @type {Object} */ -export function enableCompatibilityMode(opt_data = {}) { - compatibilityModeData_ = opt_data; +export function enableCompatibilityMode(data = {}) { + compatibilityModeData_ = data; } /** @@ -112,17 +112,22 @@ export function getFunctionName(fn) { * be recalculated even if this function is called multiple times. * @param {!function()} ctor Class constructor. * @param {string} propertyName Property name to be merged. - * @param {function(*, *):*=} opt_mergeFn Function that receives the merged + * @param {function(*, *):*=} mergeFn Function that receives the merged * value of the property so far and the next value to be merged to it. * Should return these two merged together. If not passed the final property * will be the first truthy value among ancestors. + * @return {Object} */ -export function getStaticProperty(ctor, propertyName, opt_mergeFn) { +export function getStaticProperty( + ctor, + propertyName, + mergeFn = getFirstTruthy_ +) { const mergedName = propertyName + '_MERGED'; if (!ctor.hasOwnProperty(mergedName)) { + // eslint-disable-next-line let merged = ctor.hasOwnProperty(propertyName) ? ctor[propertyName] : null; if (ctor.__proto__ && !ctor.__proto__.isPrototypeOf(Function)) { - const mergeFn = opt_mergeFn || getFirstTruthy_; merged = mergeFn( merged, getStaticProperty(ctor.__proto__, propertyName, mergeFn) @@ -134,34 +139,35 @@ export function getStaticProperty(ctor, propertyName, opt_mergeFn) { } /** - * Gets an unique id. If `opt_object` argument is passed, the object is + * Gets an unique id. If `object` argument is passed, the object is * mutated with an unique id. Consecutive calls with the same object * reference won't mutate the object again, instead the current object uid * returns. See {@link UID_PROPERTY}. - * @param {Object=} opt_object Optional object to be mutated with the uid. If + * @param {Object=} object Optional object to be mutated with the uid. If * not specified this method only returns the uid. - * @param {boolean=} opt_noInheritance Optional flag indicating if this + * @param {boolean=} noInheritance Optional flag indicating if this * object's uid property can be inherited from parents or not. * @throws {Error} when invoked to indicate the method should be overridden. + * @return {number} */ -export function getUid(opt_object, opt_noInheritance) { - if (opt_object) { - let id = opt_object[UID_PROPERTY]; - if (opt_noInheritance && !opt_object.hasOwnProperty(UID_PROPERTY)) { +export function getUid(object, noInheritance) { + if (object) { + let id = object[UID_PROPERTY]; + if (noInheritance && !object.hasOwnProperty(UID_PROPERTY)) { id = null; } - return id || (opt_object[UID_PROPERTY] = uniqueIdCounter_++); + return id || (object[UID_PROPERTY] = uniqueIdCounter_++); } return uniqueIdCounter_++; } /** * The identity function. Returns its first argument. - * @param {*=} opt_returnValue The single value that will be returned. + * @param {*=} returnValue The single value that will be returned. * @return {?} The first argument. */ -export function identityFunction(opt_returnValue) { - return opt_returnValue; +export function identityFunction(returnValue) { + return returnValue; } /** @@ -262,7 +268,7 @@ export function isWindow(val) { */ export function isObject(val) { const type = typeof val; - return type === 'object' && val !== null || type === 'function'; + return (type === 'object' && val !== null) || type === 'function'; } /** @@ -290,15 +296,16 @@ export function isString(val) { * @return {boolean} */ export function isServerSide() { - return typeof process !== 'undefined' && + return ( + typeof process !== 'undefined' && typeof process.env !== 'undefined' && process.env.NODE_ENV !== 'test' && - !process.browser; + !process.browser + ); } /** * Null function used for default values of callbacks, etc. * @return {void} Nothing. */ -export function nullFunction() { -} +export function nullFunction() {} diff --git a/packages/metal/src/disposable/Disposable.js b/packages/metal/src/disposable/Disposable.js index f8788bd2..d92ea2f6 100644 --- a/packages/metal/src/disposable/Disposable.js +++ b/packages/metal/src/disposable/Disposable.js @@ -8,6 +8,9 @@ * @constructor */ class Disposable { + /** + * Disposable constructor + */ constructor() { /** * Flag indicating if this instance has already been disposed. diff --git a/packages/metal/src/metal.js b/packages/metal/src/metal.js index 89ce955b..795af88f 100644 --- a/packages/metal/src/metal.js +++ b/packages/metal/src/metal.js @@ -8,5 +8,5 @@ import object from './object/object'; import string from './string/string'; export * from './core'; -export { array, async, Disposable, object, string }; +export {array, async, Disposable, object, string}; export default core; diff --git a/packages/metal/src/object/object.js b/packages/metal/src/object/object.js index 7ab47767..71ba8dc5 100644 --- a/packages/metal/src/object/object.js +++ b/packages/metal/src/object/object.js @@ -1,5 +1,8 @@ 'use strict'; +/** + * Set of utilities for object operations + */ class object { /** * Copies all the members of a source object to a target object. @@ -7,10 +10,14 @@ class object { * @param {...Object} var_args The objects from which values will be copied. * @return {Object} Returns the target object reference. */ - static mixin(target) { - let key, source; - for (let i = 1; i < arguments.length; i++) { - source = arguments[i]; + static mixin(target, ...args) { + let key; + let source; + for (let i = 0; i < args.length; i++) { + source = args[i]; + // Possible prototype chain leak, breaks 1 metal-dom and + // 1 metal-incremental-dom test if guard-for-in rule is addressed + // eslint-disable-next-line for (key in source) { target[key] = source[key]; } @@ -21,12 +28,11 @@ class object { /** * Returns an object based on its fully qualified external name. * @param {string} name The fully qualified name. - * @param {object=} opt_obj The object within which to look; default is + * @param {object=} scope The object within which to look; default is * window. * @return {?} The value (object or primitive) or, if not found, undefined. */ - static getObjectByName(name, opt_obj) { - const scope = opt_obj || window; + static getObjectByName(name, scope = window) { const parts = name.split('.'); return parts.reduce((part, key) => part[key], scope); } @@ -50,6 +56,8 @@ class object { /** * Checks if the two given objects are equal. This is done via a shallow * check, including only the keys directly contained by the 2 objects. + * @param {Object} obj1 + * @param {Object} obj2 * @return {boolean} */ static shallowEqual(obj1, obj2) { diff --git a/packages/metal/src/string/string.js b/packages/metal/src/string/string.js index 27c806ec..bf44dff1 100644 --- a/packages/metal/src/string/string.js +++ b/packages/metal/src/string/string.js @@ -1,5 +1,8 @@ 'use strict'; +/** + * Set of utilities for string operations + */ class string { /** * Compares the given strings without taking the case into account. @@ -29,29 +32,33 @@ class string { * @return {string} Copy of the string with normalized breaking spaces. */ static collapseBreakingSpaces(str) { - return str.replace(/[\t\r\n ]+/g, ' ').replace(/^[\t\r\n ]+|[\t\r\n ]+$/g, ''); + return str + .replace(/[\t\r\n ]+/g, ' ') + .replace(/^[\t\r\n ]+|[\t\r\n ]+$/g, ''); } /** - * Escapes characters in the string that are not safe to use in a RegExp. - * @param {*} str The string to escape. If not a string, it will be casted - * to one. - * @return {string} A RegExp safe, escaped copy of {@code s}. - */ + * Escapes characters in the string that are not safe to use in a RegExp. + * @param {*} str The string to escape. If not a string, it will be casted + * to one. + * @return {string} A RegExp safe, escaped copy of {@code s}. + */ static escapeRegex(str) { return String(str) - .replace(/([-()\[\]{}+?*.$\^|,:# a + b); + let prop = core.getStaticProperty(Test3, 'FOO', (a, b) => a + b); assert.equal(prop, 6); }); it('should not recalculate static property after set for the first time', function() { - class Test1 { - } + class Test1 {} Test1.FOO = 1; - class Test2 extends Test1 { - } + class Test2 extends Test1 {} Test2.FOO = 2; - class Test3 extends Test2 { - } + class Test3 extends Test2 {} Test3.FOO = 3; const mergeFn = sinon.stub().returns(1); - var prop = core.getStaticProperty(Test3, 'FOO', mergeFn); + let prop = core.getStaticProperty(Test3, 'FOO', mergeFn); assert.equal(2, mergeFn.callCount); assert.equal(prop, core.getStaticProperty(Test3, 'FOO', mergeFn)); @@ -105,8 +94,8 @@ describe('core', function() { it('should return the first arg passed to identity function', function() { assert.strictEqual(1, core.identityFunction(1)); - var obj = { - a: 2 + let obj = { + a: 2, }; assert.strictEqual(obj, core.identityFunction(obj)); }); @@ -154,9 +143,11 @@ describe('core', function() { assert.ok(!core.isPromise(null)); assert.ok(!core.isPromise(undefined)); - assert.ok(core.isPromise({ - then: core.nullFunction - })); + assert.ok( + core.isPromise({ + then: core.nullFunction, + }) + ); }); it('should check if var is string', function() { @@ -187,27 +178,33 @@ describe('core', function() { }); it('should check if var is element', function() { - assert.ok(core.isElement({ - nodeType: 1 - })); + assert.ok( + core.isElement({ + nodeType: 1, + }) + ); assert.ok(!core.isElement({})); assert.ok(!core.isElement(null)); assert.ok(!core.isElement(true)); }); it('should check if var is document', function() { - assert.ok(core.isDocument({ - nodeType: 9 - })); - assert.ok(!core.isDocument({ - nodeType: 1 - })); + assert.ok( + core.isDocument({ + nodeType: 9, + }) + ); + assert.ok( + !core.isDocument({ + nodeType: 1, + }) + ); assert.ok(!core.isDocument({})); assert.ok(!core.isDocument(null)); assert.ok(!core.isDocument(true)); }); - it('should check if var is document fragment', function () { + it('should check if var is document fragment', function() { assert.ok(!core.isDocumentFragment(null)); assert.ok(!core.isDocumentFragment({nodeType: 0})); assert.ok(!core.isDocumentFragment({nodeType: 9})); @@ -220,12 +217,16 @@ describe('core', function() { return; } - assert.ok(!core.isWindow({ - nodeType: 9 - })); - assert.ok(!core.isWindow({ - nodeType: 1 - })); + assert.ok( + !core.isWindow({ + nodeType: 9, + }) + ); + assert.ok( + !core.isWindow({ + nodeType: 1, + }) + ); assert.ok(core.isWindow(window)); assert.ok(!core.isWindow(null)); assert.ok(!core.isWindow(true)); @@ -264,8 +265,7 @@ describe('core', function() { describe('getFunctionName', function() { it('should return the name of the given function', function() { - function myFunction() { - } + function myFunction() {} assert.strictEqual('myFunction', core.getFunctionName(myFunction)); }); }); diff --git a/packages/metal/test/disposable/Disposable.js b/packages/metal/test/disposable/Disposable.js index b4517d5a..8c98b61e 100644 --- a/packages/metal/test/disposable/Disposable.js +++ b/packages/metal/test/disposable/Disposable.js @@ -4,7 +4,7 @@ import Disposable from '../../src/disposable/Disposable'; describe('Disposable', function() { it('should correctly inform if the instance has been disposed', function() { - var disposable = new Disposable(); + let disposable = new Disposable(); assert.ok(!disposable.isDisposed()); @@ -13,28 +13,25 @@ describe('Disposable', function() { }); it('should call `disposeInternal` when running `dispose`', function() { - class TestDisposable extends Disposable { - } + class TestDisposable extends Disposable {} TestDisposable.prototype.disposeInternal = sinon.stub(); - var testDisposable = new TestDisposable(); + let testDisposable = new TestDisposable(); testDisposable.dispose(); assert.strictEqual(1, testDisposable.disposeInternal.callCount); }); it('should not dispose more than once', function() { - class TestDisposable extends Disposable { - } + class TestDisposable extends Disposable {} TestDisposable.prototype.disposeInternal = sinon.stub(); - var testDisposable = new TestDisposable(); + let testDisposable = new TestDisposable(); testDisposable.dispose(); testDisposable.dispose(); assert.strictEqual(1, testDisposable.disposeInternal.callCount); - }); }); diff --git a/packages/metal/test/object/object.js b/packages/metal/test/object/object.js index 9db26d8b..3a6468f7 100644 --- a/packages/metal/test/object/object.js +++ b/packages/metal/test/object/object.js @@ -4,15 +4,21 @@ import object from '../../src/object/object'; describe('object', function() { it('should mixin object arguments', function() { - var original = {}; + let original = {}; - var mixin = object.mixin(original, { - a: 1 - }, { - b: 1 - }, { - b: 2 - }, null); + let mixin = object.mixin( + original, + { + a: 1, + }, + { + b: 1, + }, + { + b: 2, + }, + null + ); assert.strictEqual(original, mixin); assert.strictEqual(1, mixin.a); @@ -21,9 +27,9 @@ describe('object', function() { }); it('should mixin array arguments', function() { - var original = []; + let original = []; - var mixin = object.mixin(original, [null, 2, 3], [1]); + let mixin = object.mixin(original, [null, 2, 3], [1]); assert.strictEqual(original, mixin); assert.deepEqual([1, 2, 3], mixin); @@ -35,52 +41,52 @@ describe('object', function() { return; } window.Foo = { - Bar: 1 + Bar: 1, }; assert.strictEqual(1, object.getObjectByName('Foo.Bar')); assert.strictEqual(undefined, object.getObjectByName('Foo.Bar.None')); }); it('should get object by name from object', function() { - var obj = { + let obj = { Foo: { - Bar: 1 - } + Bar: 1, + }, }; assert.strictEqual(1, object.getObjectByName('Foo.Bar', obj)); assert.strictEqual(undefined, object.getObjectByName('Foo.Bar.None', obj)); }); it('should map an object\'s content to a new object', function() { - var obj = { + let obj = { a: 1, - b: 2 + b: 2, }; - var mappedObj = object.map(obj, (key, value) => key + ':' + value); - var expectedObj = { + let mappedObj = object.map(obj, (key, value) => key + ':' + value); + let expectedObj = { a: 'a:1', - b: 'b:2' + b: 'b:2', }; assert.deepEqual(expectedObj, mappedObj); }); it('should check if two objects are shallowly equal', function() { - var obj1 = {}; + let obj1 = {}; assert.ok(object.shallowEqual(obj1, obj1)); - var obj2 = { - a: 1 + let obj2 = { + a: 1, }; assert.ok(!object.shallowEqual(obj1, obj2)); - var obj3 = { - a: 1 + let obj3 = { + a: 1, }; assert.ok(!object.shallowEqual(obj1, obj3)); assert.ok(object.shallowEqual(obj2, obj3)); - var obj4 = { - a: 2 + let obj4 = { + a: 2, }; assert.ok(!object.shallowEqual(obj1, obj4)); assert.ok(!object.shallowEqual(obj2, obj4)); diff --git a/packages/metal/test/string/string.js b/packages/metal/test/string/string.js index e27a4921..4309384c 100644 --- a/packages/metal/test/string/string.js +++ b/packages/metal/test/string/string.js @@ -15,7 +15,10 @@ describe('string', function() { }); it('should collapse breaking spaces', function() { - assert.strictEqual('foo bar', string.collapseBreakingSpaces(' foo bar ')); + assert.strictEqual( + 'foo bar', + string.collapseBreakingSpaces(' foo bar ') + ); }); it('should generate random strings', function() { @@ -27,8 +30,8 @@ describe('string', function() { }); it('should escape regex', function() { - var spec = '()[]{}+-?*.$^|,:#