diff --git a/scripts/build.js b/scripts/build.js index 27147148..9d0e81e4 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -48,7 +48,7 @@ function buildEntry (config) { .then(bundle => bundle.generate(output)) .then(({ code }) => { if (isProd) { - var minified = (banner ? banner + '\n' : '') + terser.minify(code, { + const minified = (banner ? banner + '\n' : '') + terser.minify(code, { output: { ascii_only: true }, diff --git a/scripts/get-weex-version.js b/scripts/get-weex-version.js index d701c432..f66492b3 100644 --- a/scripts/get-weex-version.js +++ b/scripts/get-weex-version.js @@ -1,7 +1,7 @@ -var coreVersion = require('../package.json').version -var weexVersion = require('../packages/weex-vue-framework/package.json').version -var weexBaseVersion = weexVersion.match(/^[\d.]+/)[0] -var weexSubVersion = Number(weexVersion.match(/-weex\.(\d+)$/)[1]) +const coreVersion = require('../package.json').version +const weexVersion = require('../packages/weex-vue-framework/package.json').version +let weexBaseVersion = weexVersion.match(/^[\d.]+/)[0] +let weexSubVersion = Number(weexVersion.match(/-weex\.(\d+)$/)[1]) if (weexBaseVersion === coreVersion) { // same core version, increment sub version diff --git a/src/platforms/web/runtime/components/transition-group.js b/src/platforms/web/runtime/components/transition-group.js index 81d033d5..2a23a15c 100644 --- a/src/platforms/web/runtime/components/transition-group.js +++ b/src/platforms/web/runtime/components/transition-group.js @@ -111,8 +111,8 @@ export default { children.forEach((c: VNode) => { if (c.data.moved) { - var el: any = c.elm - var s: any = el.style + const el: any = c.elm + const s: any = el.style addTransitionClass(el, moveClass) s.transform = s.WebkitTransform = s.transitionDuration = '' el.addEventListener(transitionEndEvent, el._moveCb = function cb (e) { diff --git a/src/platforms/web/util/style.js b/src/platforms/web/util/style.js index fc119043..faa3db38 100644 --- a/src/platforms/web/util/style.js +++ b/src/platforms/web/util/style.js @@ -8,7 +8,7 @@ export const parseStyleText = cached(function (cssText) { const propertyDelimiter = /:(.+)/ cssText.split(listDelimiter).forEach(function (item) { if (item) { - var tmp = item.split(propertyDelimiter) + const tmp = item.split(propertyDelimiter) tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim()) } }) diff --git a/src/platforms/weex/runtime/modules/style.js b/src/platforms/weex/runtime/modules/style.js index bdabd17b..0ec217b3 100755 --- a/src/platforms/weex/runtime/modules/style.js +++ b/src/platforms/weex/runtime/modules/style.js @@ -70,7 +70,7 @@ function updateStyle (oldVnode: VNodeWithData, vnode: VNodeWithData) { function toObject (arr) { const res = {} - for (var i = 0; i < arr.length; i++) { + for (let i = 0; i < arr.length; i++) { if (arr[i]) { extend(res, arr[i]) } diff --git a/test/e2e/runner.js b/test/e2e/runner.js index d59506d9..dadce70d 100644 --- a/test/e2e/runner.js +++ b/test/e2e/runner.js @@ -1,25 +1,25 @@ -var path = require('path') -var spawn = require('cross-spawn') -var httpServer = require('http-server') -var server = httpServer.createServer({ +const path = require('path') +const spawn = require('cross-spawn') +const httpServer = require('http-server') +const server = httpServer.createServer({ root: path.resolve(__dirname, '../../') }) server.listen(8080) -var args = process.argv.slice(2) +let args = process.argv.slice(2) if (args.indexOf('--config') === -1) { args = args.concat(['--config', 'test/e2e/nightwatch.config.js']) } if (args.indexOf('--env') === -1) { args = args.concat(['--env', 'chrome,phantomjs']) } -var i = args.indexOf('--test') +const i = args.indexOf('--test') if (i > -1) { args[i + 1] = 'test/e2e/specs/' + args[i + 1] + '.js' } -var runner = spawn('./node_modules/.bin/nightwatch', args, { +const runner = spawn('./node_modules/.bin/nightwatch', args, { stdio: 'inherit' }) diff --git a/test/e2e/specs/grid.js b/test/e2e/specs/grid.js index 7c273359..ab635b28 100644 --- a/test/e2e/specs/grid.js +++ b/test/e2e/specs/grid.js @@ -1,6 +1,6 @@ module.exports = { 'grid': function (browser) { - var columns = ['name', 'power'] + const columns = ['name', 'power'] browser .url('http://localhost:8080/examples/grid/') @@ -92,8 +92,8 @@ module.exports = { function assertTable (data) { browser.assert.count('td', data.length * columns.length) - for (var i = 0; i < data.length; i++) { - for (var j = 0; j < columns.length; j++) { + for (let i = 0; i < data.length; i++) { + for (let j = 0; j < columns.length; j++) { browser.assert.containsText( 'tr:nth-child(' + (i + 1) + ') td:nth-child(' + (j + 1) + ')', data[i][columns[j]] diff --git a/test/e2e/specs/svg.js b/test/e2e/specs/svg.js index 7726bff5..cc9af55f 100644 --- a/test/e2e/specs/svg.js +++ b/test/e2e/specs/svg.js @@ -12,8 +12,8 @@ module.exports = { .assert.count('button', 7) .assert.count('input[type="range"]', 6) .assert.evaluate(function () { - var points = stats.map(function (stat, i) { - var point = valueToPoint(stat.value, i, 6) + const points = stats.map(function (stat, i) { + const point = valueToPoint(stat.value, i, 6) return point.x + ',' + point.y }).join(' ') return document.querySelector('polygon').attributes[0].value === points @@ -24,8 +24,8 @@ module.exports = { .assert.count('button', 6) .assert.count('input[type="range"]', 5) .assert.evaluate(function () { - var points = stats.map(function (stat, i) { - var point = valueToPoint(stat.value, i, 5) + const points = stats.map(function (stat, i) { + const point = valueToPoint(stat.value, i, 5) return point.x + ',' + point.y }).join(' ') return document.querySelector('polygon').attributes[0].value === points @@ -37,8 +37,8 @@ module.exports = { .assert.count('button', 7) .assert.count('input[type="range"]', 6) .assert.evaluate(function () { - var points = stats.map(function (stat, i) { - var point = valueToPoint(stat.value, i, 6) + const points = stats.map(function (stat, i) { + const point = valueToPoint(stat.value, i, 6) return point.x + ',' + point.y }).join(' ') return document.querySelector('polygon').attributes[0].value === points diff --git a/test/e2e/specs/tree.js b/test/e2e/specs/tree.js index 92ae25d7..08df908a 100644 --- a/test/e2e/specs/tree.js +++ b/test/e2e/specs/tree.js @@ -63,8 +63,8 @@ module.exports = { .assert.count('.item > ul', 5) .assert.containsText('#demo ul > .item:nth-child(1)', '[-]') .assert.evaluate(function () { - var firstItem = document.querySelector('#demo ul > .item:nth-child(1)') - var ul = firstItem.querySelector('ul') + const firstItem = document.querySelector('#demo ul > .item:nth-child(1)') + const ul = firstItem.querySelector('ul') return ul.children.length === 2 }) .end() diff --git a/test/helpers/to-have-been-warned.js b/test/helpers/to-have-been-warned.js index 097b0e6e..b3a5eaae 100644 --- a/test/helpers/to-have-been-warned.js +++ b/test/helpers/to-have-been-warned.js @@ -14,8 +14,8 @@ let asserted function createCompareFn (spy) { const hasWarned = msg => { - var count = spy.calls.count() - var args + let count = spy.calls.count() + let args while (count--) { args = spy.calls.argsFor(count) if (args.some(containsMsg)) { @@ -31,7 +31,7 @@ function createCompareFn (spy) { return { compare: msg => { asserted = asserted.concat(msg) - var warned = Array.isArray(msg) + const warned = Array.isArray(msg) ? msg.some(hasWarned) : hasWarned(msg) return { diff --git a/test/helpers/trigger-event.js b/test/helpers/trigger-event.js index 12ea7e2b..4cd5d79d 100644 --- a/test/helpers/trigger-event.js +++ b/test/helpers/trigger-event.js @@ -1,5 +1,5 @@ window.triggerEvent = function triggerEvent (target, event, process) { - var e = document.createEvent('HTMLEvents') + const e = document.createEvent('HTMLEvents') e.initEvent(event, true, true) if (process) process(e) target.dispatchEvent(e) diff --git a/test/ssr/ssr-stream.spec.js b/test/ssr/ssr-stream.spec.js index b18707ab..5973b5ed 100644 --- a/test/ssr/ssr-stream.spec.js +++ b/test/ssr/ssr-stream.spec.js @@ -89,9 +89,9 @@ describe('SSR: renderToStream', () => { template: `
`, _scopeId: '_component2' }) - var stream1 = renderToStream(component1) - var stream2 = renderToStream(component2) - var res = '' + const stream1 = renderToStream(component1) + const stream2 = renderToStream(component2) + let res = '' stream1.on('data', (text) => { res += text.toString('utf-8').replace(/x/g, '') }) diff --git a/test/unit/features/component/component-async.spec.js b/test/unit/features/component/component-async.spec.js index 889cb714..6e057b81 100644 --- a/test/unit/features/component/component-async.spec.js +++ b/test/unit/features/component/component-async.spec.js @@ -79,7 +79,7 @@ describe('Component async', () => { }) it('dynamic', done => { - var vm = new Vue({ + const vm = new Vue({ template: '' + item.a + '
' + (item.a + 1) + '
' }).join('') expect(vm.$el.innerHTML).toBe(markup) @@ -370,7 +370,7 @@ describe('Directive v-for', () => { }).then(done) function assertMarkup () { - var markup = vm.list.map(function (item) { + const markup = vm.list.map(function (item) { return `${item.a}${item.a}
` }).join('') expect(vm.$el.innerHTML).toBe(markup) diff --git a/test/unit/features/directives/model-radio.spec.js b/test/unit/features/directives/model-radio.spec.js index 4b3886c2..3ff4e50b 100644 --- a/test/unit/features/directives/model-radio.spec.js +++ b/test/unit/features/directives/model-radio.spec.js @@ -117,7 +117,7 @@ describe('Directive v-model radio', () => { '' }).$mount() document.body.appendChild(vm.$el) - var inputs = vm.$el.getElementsByTagName('input') + const inputs = vm.$el.getElementsByTagName('input') inputs[1].click() waitForUpdate(() => { expect(vm.selections).toEqual(['b', '1']) @@ -160,7 +160,7 @@ describe('Directive v-model radio', () => { '' + '' }).$mount() - var radioboxInput = vm.$el.children + const radioboxInput = vm.$el.children expect(radioboxInput[0].checked).toBe(false) expect(radioboxInput[1].checked).toBe(false) expect(radioboxInput[2].checked).toBe(true) diff --git a/test/unit/features/directives/model-select.spec.js b/test/unit/features/directives/model-select.spec.js index 2bf5cb4d..4fffe73a 100644 --- a/test/unit/features/directives/model-select.spec.js +++ b/test/unit/features/directives/model-select.spec.js @@ -4,9 +4,9 @@ import { looseEqual } from 'shared/util' // Android 4.4 Chrome 30 has the bug that a multi-select option cannot be // deselected by setting its "selected" prop via JavaScript. function hasMultiSelectBug () { - var s = document.createElement('select') + const s = document.createElement('select') s.setAttribute('multiple', '') - var o = document.createElement('option') + const o = document.createElement('option') s.appendChild(o) o.selected = true o.selected = false @@ -18,8 +18,8 @@ function hasMultiSelectBug () { * we have to manually loop through the options */ function updateSelect (el, value) { - var options = el.options - var i = options.length + const options = el.options + let i = options.length while (i--) { if (looseEqual(getValue(options[i]), value)) { options[i].selected = true @@ -245,7 +245,7 @@ describe('Directive v-model select', () => { '' + '' }).$mount() - var opts = vm.$el.options + const opts = vm.$el.options expect(opts[0].selected).toBe(false) expect(opts[1].selected).toBe(true) expect(opts[2].selected).toBe(false) @@ -272,7 +272,7 @@ describe('Directive v-model select', () => { '' + '' }).$mount() - var opts = vm.$el.options + const opts = vm.$el.options expect(opts[0].selected).toBe(false) expect(opts[1].selected).toBe(true) expect(opts[2].selected).toBe(false) @@ -345,7 +345,7 @@ describe('Directive v-model select', () => { '' + '' }).$mount() - var opts = vm.$el.options + const opts = vm.$el.options expect(opts[0].selected).toBe(true) expect(opts[1].selected).toBe(true) expect(opts[2].selected).toBe(true) @@ -379,8 +379,8 @@ describe('Directive v-model select', () => { '' }).$mount() document.body.appendChild(vm.$el) - var selects = vm.$el.getElementsByTagName('select') - var select0 = selects[0] + const selects = vm.$el.getElementsByTagName('select') + const select0 = selects[0] select0.options[0].selected = true triggerEvent(select0, 'change') waitForUpdate(() => { @@ -421,7 +421,7 @@ describe('Directive v-model select', () => { '' + '' }).$mount() - var opts = vm.$el.options + const opts = vm.$el.options expect(opts[0].selected).toBe(false) expect(opts[1].selected).toBe(true) expect(opts[2].selected).toBe(false) diff --git a/test/unit/features/directives/model-text.spec.js b/test/unit/features/directives/model-text.spec.js index 7ae44f9f..d9adfb9c 100644 --- a/test/unit/features/directives/model-text.spec.js +++ b/test/unit/features/directives/model-text.spec.js @@ -167,7 +167,7 @@ describe('Directive v-model text', () => { '{{selections}}' + '' }).$mount() - var inputs = vm.$el.getElementsByTagName('input') + const inputs = vm.$el.getElementsByTagName('input') inputs[1].value = 'test' triggerEvent(inputs[1], 'input') waitForUpdate(() => { diff --git a/test/unit/features/directives/style.spec.js b/test/unit/features/directives/style.spec.js index 1d8f68b7..43f527be 100644 --- a/test/unit/features/directives/style.spec.js +++ b/test/unit/features/directives/style.spec.js @@ -1,11 +1,11 @@ import Vue from 'vue' function checkPrefixedProp (prop) { - var el = document.createElement('div') - var upper = prop.charAt(0).toUpperCase() + prop.slice(1) + const el = document.createElement('div') + const upper = prop.charAt(0).toUpperCase() + prop.slice(1) if (!(prop in el.style)) { - var prefixes = ['Webkit', 'Moz', 'ms'] - var i = prefixes.length + const prefixes = ['Webkit', 'Moz', 'ms'] + let i = prefixes.length while (i--) { if ((prefixes[i] + upper) in el.style) { prop = prefixes[i] + upper diff --git a/test/unit/features/instance/methods-data.spec.js b/test/unit/features/instance/methods-data.spec.js index 8684c69e..1c7fc144 100644 --- a/test/unit/features/instance/methods-data.spec.js +++ b/test/unit/features/instance/methods-data.spec.js @@ -73,7 +73,7 @@ describe('Instance methods data', () => { }) it('deep watch', done => { - var oldA = vm.a + const oldA = vm.a vm.$watch('a', spy, { deep: true }) vm.a.b = 2 waitForUpdate(() => { @@ -85,7 +85,7 @@ describe('Instance methods data', () => { }) it('handler option', done => { - var oldA = vm.a + const oldA = vm.a vm.$watch('a', { handler: spy, deep: true diff --git a/test/unit/features/instance/methods-events.spec.js b/test/unit/features/instance/methods-events.spec.js index 88834577..5cf43986 100644 --- a/test/unit/features/instance/methods-events.spec.js +++ b/test/unit/features/instance/methods-events.spec.js @@ -77,7 +77,7 @@ describe('Instance methods events', () => { }) it('$off event + fn', () => { - var spy2 = jasmine.createSpy('emitter') + const spy2 = jasmine.createSpy('emitter') vm.$on('test', spy) vm.$on('test', spy2) vm.$off('test', spy) diff --git a/test/unit/features/options/functional.spec.js b/test/unit/features/options/functional.spec.js index 2c6abe95..b5fb67bd 100644 --- a/test/unit/features/options/functional.spec.js +++ b/test/unit/features/options/functional.spec.js @@ -244,8 +244,8 @@ describe('Options functional', () => { it('should work with render fns compiled from template', done => { // code generated via vue-template-es2015-compiler - var render = function (_h, _vm) { - var _c = _vm._c + const render = function (_h, _vm) { + const _c = _vm._c return _c( 'div', [ @@ -261,9 +261,9 @@ describe('Options functional', () => { 2 ) } - var staticRenderFns = [ + const staticRenderFns = [ function (_h, _vm) { - var _c = _vm._c + const _c = _vm._c return _c('div', [_vm._v('Some '), _c('span', [_vm._v('text')])]) } ] diff --git a/test/unit/features/options/watch.spec.js b/test/unit/features/options/watch.spec.js index e16b2f83..a14233c8 100644 --- a/test/unit/features/options/watch.spec.js +++ b/test/unit/features/options/watch.spec.js @@ -106,9 +106,9 @@ describe('Options watch', () => { }) it('correctly merges multiple extends', done => { - var spy2 = jasmine.createSpy('A') - var spy3 = jasmine.createSpy('B') - var A = Vue.extend({ + const spy2 = jasmine.createSpy('A') + const spy3 = jasmine.createSpy('B') + const A = Vue.extend({ data: function () { return { a: 0, @@ -120,21 +120,21 @@ describe('Options watch', () => { } }) - var B = Vue.extend({ + const B = Vue.extend({ extends: A, watch: { a: spy2 } }) - var C = Vue.extend({ + const C = Vue.extend({ extends: B, watch: { a: spy3 } }) - var vm = new C() + const vm = new C() vm.a = 1 waitForUpdate(() => { diff --git a/test/unit/features/transition/inject-styles.js b/test/unit/features/transition/inject-styles.js index 2304e3d5..34185096 100644 --- a/test/unit/features/transition/inject-styles.js +++ b/test/unit/features/transition/inject-styles.js @@ -1,5 +1,5 @@ function insertCSS (text) { - var cssEl = document.createElement('style') + const cssEl = document.createElement('style') cssEl.textContent = text.trim() document.head.appendChild(cssEl) } diff --git a/test/unit/karma.base.config.js b/test/unit/karma.base.config.js index 8f0a706d..2b30378f 100644 --- a/test/unit/karma.base.config.js +++ b/test/unit/karma.base.config.js @@ -1,7 +1,7 @@ -var alias = require('../../scripts/alias') -var webpack = require('webpack') +const alias = require('../../scripts/alias') +const webpack = require('webpack') -var webpackConfig = { +const webpackConfig = { mode: 'development', resolve: { alias: alias diff --git a/test/unit/karma.cover.config.js b/test/unit/karma.cover.config.js index 360252a6..e1801548 100644 --- a/test/unit/karma.cover.config.js +++ b/test/unit/karma.cover.config.js @@ -1,7 +1,7 @@ -var base = require('./karma.base.config.js') +const base = require('./karma.base.config.js') module.exports = function (config) { - var options = Object.assign(base, { + const options = Object.assign(base, { browsers: ['PhantomJS'], reporters: ['mocha', 'coverage'], coverageReporter: { diff --git a/test/unit/karma.dev.config.js b/test/unit/karma.dev.config.js index 9285861e..f9dfc1b6 100644 --- a/test/unit/karma.dev.config.js +++ b/test/unit/karma.dev.config.js @@ -1,4 +1,4 @@ -var base = require('./karma.base.config.js') +const base = require('./karma.base.config.js') module.exports = function (config) { config.set(Object.assign(base, { diff --git a/test/unit/karma.sauce.config.js b/test/unit/karma.sauce.config.js index 55672b56..0c4ab227 100644 --- a/test/unit/karma.sauce.config.js +++ b/test/unit/karma.sauce.config.js @@ -1,5 +1,5 @@ -var webpack = require('webpack') -var base = require('./karma.base.config.js') +const webpack = require('webpack') +const base = require('./karma.base.config.js') base.webpack.plugins = [ new webpack.DefinePlugin({ @@ -19,7 +19,7 @@ base.webpack.plugins = [ * smaller batches. */ -var batches = [ +const batches = [ // the cool kids { sl_chrome: { @@ -79,7 +79,7 @@ var batches = [ ] module.exports = function (config) { - var batch = batches[process.argv[4] || 0] + const batch = batches[process.argv[4] || 0] config.set(Object.assign(base, { singleRun: true, diff --git a/test/unit/karma.unit.config.js b/test/unit/karma.unit.config.js index 7840df74..a9337064 100644 --- a/test/unit/karma.unit.config.js +++ b/test/unit/karma.unit.config.js @@ -1,4 +1,4 @@ -var base = require('./karma.base.config.js') +const base = require('./karma.base.config.js') module.exports = function (config) { config.set(Object.assign(base, {