From 84418dc634dfaee14bc4e2c5c1862450c1a4b512 Mon Sep 17 00:00:00 2001 From: Marais Rossouw Date: Mon, 13 Jun 2016 12:19:06 +1000 Subject: [PATCH 1/3] refactor: `.test` is faster than `.match` for regex bools --- packages/vue-server-renderer/index.js | 28 ++++++++----------- packages/vue-template-compiler/index.js | 8 ++++-- src/core/util/env.js | 4 +-- src/platforms/web/runtime/directives/model.js | 2 +- 4 files changed, 20 insertions(+), 22 deletions(-) diff --git a/packages/vue-server-renderer/index.js b/packages/vue-server-renderer/index.js index 3a5cd7d3403..32e3e50ff30 100644 --- a/packages/vue-server-renderer/index.js +++ b/packages/vue-server-renderer/index.js @@ -4,9 +4,7 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau var stream = _interopDefault(require('stream')); -var babelHelpers = {}; - -babelHelpers.inherits = function (subClass, superClass) { +var inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } @@ -22,7 +20,7 @@ babelHelpers.inherits = function (subClass, superClass) { if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }; -babelHelpers.possibleConstructorReturn = function (self, call) { +var possibleConstructorReturn = function (self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } @@ -30,8 +28,6 @@ babelHelpers.possibleConstructorReturn = function (self, call) { return call && (typeof call === "object" || typeof call === "function") ? call : self; }; -babelHelpers; - /** * Original RenderStream implmentation by Sasha Aickin (@aickin) * Licensed under the Apache License, Version 2.0 @@ -39,10 +35,10 @@ babelHelpers; */ var RenderStream = function (_stream$Readable) { - babelHelpers.inherits(RenderStream, _stream$Readable); + inherits(RenderStream, _stream$Readable); function RenderStream(render) { - var _this = babelHelpers.possibleConstructorReturn(this, _stream$Readable.call(this)); + var _this = possibleConstructorReturn(this, _stream$Readable.call(this)); _this.buffer = ''; _this.render = render; @@ -234,7 +230,7 @@ function bind(fn, ctx) { /** * Convert an Array-like object to a real Array. */ -function toArray(list, start) { +function toArray$1(list, start) { start = start || 0; var i = list.length - start; var ret = new Array(i); @@ -353,7 +349,7 @@ var inBrowser = typeof window !== 'undefined' && Object.prototype.toString.call( // UA sniffing for working around browser-specific quirks var UA = inBrowser && window.navigator.userAgent.toLowerCase(); var isIos = UA && /(iphone|ipad|ipod|ios)/i.test(UA); -var iosVersionMatch = UA && isIos && UA.match(/os ([\d_]+)/); +var iosVersionMatch = UA && isIos && /os ([\d_]+)/.test(UA); var iosVersion = iosVersionMatch && iosVersionMatch[1].split('_'); // MutationObserver is unreliable in iOS 9.3 UIWebView @@ -417,7 +413,7 @@ var nextTick = function () { var Set$1 = void 0; /* istanbul ignore if */ -if (typeof Set !== 'undefined' && Set.toString().match(/native code/)) { +if (typeof Set !== 'undefined' && /native code/.test(Set.toString())) { // use native Set when available. Set$1 = Set; } else { @@ -772,7 +768,7 @@ function defineReactive(obj, key, val, customSetter) { * triggers change notification if the property doesn't * already exist. */ -function set(obj, key, val) { +function set$1(obj, key, val) { if (Array.isArray(obj)) { obj.splice(key, 1, val); return val; @@ -854,7 +850,7 @@ function mergeData(to, from) { toVal = to[key]; fromVal = from[key]; if (!hasOwn(to, key)) { - set(to, key, fromVal); + set$1(to, key, fromVal); } else if (isObject(toVal) && isObject(fromVal)) { mergeData(toVal, fromVal); } @@ -2182,8 +2178,8 @@ function eventsMixin(Vue) { var vm = this; var cbs = vm._events[event]; if (cbs) { - cbs = cbs.length > 1 ? toArray(cbs) : cbs; - var args = toArray(arguments, 1); + cbs = cbs.length > 1 ? toArray$1(cbs) : cbs; + var args = toArray$1(arguments, 1); for (var i = 0, l = cbs.length; i < l; i++) { cbs[i].apply(vm, args); } @@ -2397,7 +2393,7 @@ function initInternalComponent(vm, options) { opts._componentTag = options._componentTag; if (options.render) { opts.render = options.render; - opts.staticRenderFns = opts.staticRenderFns; + opts.staticRenderFns = options.staticRenderFns; } } diff --git a/packages/vue-template-compiler/index.js b/packages/vue-template-compiler/index.js index b7747c57445..dfbc9765b0e 100644 --- a/packages/vue-template-compiler/index.js +++ b/packages/vue-template-compiler/index.js @@ -1,5 +1,7 @@ 'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); + function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } var entities = require('entities'); @@ -324,7 +326,7 @@ var inBrowser = typeof window !== 'undefined' && Object.prototype.toString.call( // UA sniffing for working around browser-specific quirks var UA$1 = inBrowser && window.navigator.userAgent.toLowerCase(); var isIos = UA$1 && /(iphone|ipad|ipod|ios)/i.test(UA$1); -var iosVersionMatch = UA$1 && isIos && UA$1.match(/os ([\d_]+)/); +var iosVersionMatch = UA$1 && isIos && /os ([\d_]+)/.test(UA$1); var iosVersion = iosVersionMatch && iosVersionMatch[1].split('_'); // MutationObserver is unreliable in iOS 9.3 UIWebView @@ -388,7 +390,7 @@ var nextTick = function () { var Set$1 = void 0; /* istanbul ignore if */ -if (typeof Set !== 'undefined' && Set.toString().match(/native code/)) { +if (typeof Set !== 'undefined' && /native code/.test(Set.toString())) { // use native Set when available. Set$1 = Set; } else { @@ -2104,7 +2106,7 @@ function initInternalComponent(vm, options) { opts._componentTag = options._componentTag; if (options.render) { opts.render = options.render; - opts.staticRenderFns = opts.staticRenderFns; + opts.staticRenderFns = options.staticRenderFns; } } diff --git a/src/core/util/env.js b/src/core/util/env.js index 34e65cf290f..068348913af 100644 --- a/src/core/util/env.js +++ b/src/core/util/env.js @@ -15,7 +15,7 @@ export const devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__ // UA sniffing for working around browser-specific quirks const UA = inBrowser && window.navigator.userAgent.toLowerCase() const isIos = UA && /(iphone|ipad|ipod|ios)/i.test(UA) -const iosVersionMatch = UA && isIos && UA.match(/os ([\d_]+)/) +const iosVersionMatch = UA && isIos && /os ([\d_]+)/.test(UA) const iosVersion = iosVersionMatch && iosVersionMatch[1].split('_') // MutationObserver is unreliable in iOS 9.3 UIWebView @@ -83,7 +83,7 @@ export const nextTick = (function () { let _Set /* istanbul ignore if */ -if (typeof Set !== 'undefined' && Set.toString().match(/native code/)) { +if (typeof Set !== 'undefined' && /native code/.test(Set.toString())) { // use native Set when available. _Set = Set } else { diff --git a/src/platforms/web/runtime/directives/model.js b/src/platforms/web/runtime/directives/model.js index e641163d2ea..7ebd8505042 100644 --- a/src/platforms/web/runtime/directives/model.js +++ b/src/platforms/web/runtime/directives/model.js @@ -20,7 +20,7 @@ if (isIE9) { export default { bind (el, binding, vnode) { if (process.env.NODE_ENV !== 'production') { - if (!vnode.tag.match(/input|select|textarea/)) { + if (!/input|select|textarea/.test(vnode.tag)) { warn( `v-model is not supported on element type: <${vnode.tag}>. ` + 'If you are working with contenteditable, it\'s recommended to ' + From 8fe748721f716569b54c645a44419805b60329d1 Mon Sep 17 00:00:00 2001 From: Marais Rossouw Date: Mon, 13 Jun 2016 12:22:20 +1000 Subject: [PATCH 2/3] chore: whoops.. wasnt suppose to commit these files --- packages/vue-server-renderer/index.js | 28 ++++++++++++++----------- packages/vue-template-compiler/index.js | 8 +++---- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/packages/vue-server-renderer/index.js b/packages/vue-server-renderer/index.js index 32e3e50ff30..3a5cd7d3403 100644 --- a/packages/vue-server-renderer/index.js +++ b/packages/vue-server-renderer/index.js @@ -4,7 +4,9 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau var stream = _interopDefault(require('stream')); -var inherits = function (subClass, superClass) { +var babelHelpers = {}; + +babelHelpers.inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } @@ -20,7 +22,7 @@ var inherits = function (subClass, superClass) { if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }; -var possibleConstructorReturn = function (self, call) { +babelHelpers.possibleConstructorReturn = function (self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } @@ -28,6 +30,8 @@ var possibleConstructorReturn = function (self, call) { return call && (typeof call === "object" || typeof call === "function") ? call : self; }; +babelHelpers; + /** * Original RenderStream implmentation by Sasha Aickin (@aickin) * Licensed under the Apache License, Version 2.0 @@ -35,10 +39,10 @@ var possibleConstructorReturn = function (self, call) { */ var RenderStream = function (_stream$Readable) { - inherits(RenderStream, _stream$Readable); + babelHelpers.inherits(RenderStream, _stream$Readable); function RenderStream(render) { - var _this = possibleConstructorReturn(this, _stream$Readable.call(this)); + var _this = babelHelpers.possibleConstructorReturn(this, _stream$Readable.call(this)); _this.buffer = ''; _this.render = render; @@ -230,7 +234,7 @@ function bind(fn, ctx) { /** * Convert an Array-like object to a real Array. */ -function toArray$1(list, start) { +function toArray(list, start) { start = start || 0; var i = list.length - start; var ret = new Array(i); @@ -349,7 +353,7 @@ var inBrowser = typeof window !== 'undefined' && Object.prototype.toString.call( // UA sniffing for working around browser-specific quirks var UA = inBrowser && window.navigator.userAgent.toLowerCase(); var isIos = UA && /(iphone|ipad|ipod|ios)/i.test(UA); -var iosVersionMatch = UA && isIos && /os ([\d_]+)/.test(UA); +var iosVersionMatch = UA && isIos && UA.match(/os ([\d_]+)/); var iosVersion = iosVersionMatch && iosVersionMatch[1].split('_'); // MutationObserver is unreliable in iOS 9.3 UIWebView @@ -413,7 +417,7 @@ var nextTick = function () { var Set$1 = void 0; /* istanbul ignore if */ -if (typeof Set !== 'undefined' && /native code/.test(Set.toString())) { +if (typeof Set !== 'undefined' && Set.toString().match(/native code/)) { // use native Set when available. Set$1 = Set; } else { @@ -768,7 +772,7 @@ function defineReactive(obj, key, val, customSetter) { * triggers change notification if the property doesn't * already exist. */ -function set$1(obj, key, val) { +function set(obj, key, val) { if (Array.isArray(obj)) { obj.splice(key, 1, val); return val; @@ -850,7 +854,7 @@ function mergeData(to, from) { toVal = to[key]; fromVal = from[key]; if (!hasOwn(to, key)) { - set$1(to, key, fromVal); + set(to, key, fromVal); } else if (isObject(toVal) && isObject(fromVal)) { mergeData(toVal, fromVal); } @@ -2178,8 +2182,8 @@ function eventsMixin(Vue) { var vm = this; var cbs = vm._events[event]; if (cbs) { - cbs = cbs.length > 1 ? toArray$1(cbs) : cbs; - var args = toArray$1(arguments, 1); + cbs = cbs.length > 1 ? toArray(cbs) : cbs; + var args = toArray(arguments, 1); for (var i = 0, l = cbs.length; i < l; i++) { cbs[i].apply(vm, args); } @@ -2393,7 +2397,7 @@ function initInternalComponent(vm, options) { opts._componentTag = options._componentTag; if (options.render) { opts.render = options.render; - opts.staticRenderFns = options.staticRenderFns; + opts.staticRenderFns = opts.staticRenderFns; } } diff --git a/packages/vue-template-compiler/index.js b/packages/vue-template-compiler/index.js index dfbc9765b0e..b7747c57445 100644 --- a/packages/vue-template-compiler/index.js +++ b/packages/vue-template-compiler/index.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } var entities = require('entities'); @@ -326,7 +324,7 @@ var inBrowser = typeof window !== 'undefined' && Object.prototype.toString.call( // UA sniffing for working around browser-specific quirks var UA$1 = inBrowser && window.navigator.userAgent.toLowerCase(); var isIos = UA$1 && /(iphone|ipad|ipod|ios)/i.test(UA$1); -var iosVersionMatch = UA$1 && isIos && /os ([\d_]+)/.test(UA$1); +var iosVersionMatch = UA$1 && isIos && UA$1.match(/os ([\d_]+)/); var iosVersion = iosVersionMatch && iosVersionMatch[1].split('_'); // MutationObserver is unreliable in iOS 9.3 UIWebView @@ -390,7 +388,7 @@ var nextTick = function () { var Set$1 = void 0; /* istanbul ignore if */ -if (typeof Set !== 'undefined' && /native code/.test(Set.toString())) { +if (typeof Set !== 'undefined' && Set.toString().match(/native code/)) { // use native Set when available. Set$1 = Set; } else { @@ -2106,7 +2104,7 @@ function initInternalComponent(vm, options) { opts._componentTag = options._componentTag; if (options.render) { opts.render = options.render; - opts.staticRenderFns = options.staticRenderFns; + opts.staticRenderFns = opts.staticRenderFns; } } From 9dd0b835ed6f08fa0c008763dbebf66fedfb1e89 Mon Sep 17 00:00:00 2001 From: Marais Rossouw Date: Tue, 14 Jun 2016 08:34:10 +1000 Subject: [PATCH 3/3] fix: mixxup from the iOS version match --- src/core/util/env.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/util/env.js b/src/core/util/env.js index 4b153a37962..feebbfe660c 100644 --- a/src/core/util/env.js +++ b/src/core/util/env.js @@ -15,7 +15,7 @@ export const devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__ // UA sniffing for working around browser-specific quirks export const UA = inBrowser && window.navigator.userAgent.toLowerCase() const isIos = UA && /(iphone|ipad|ipod|ios)/i.test(UA) -const iosVersionMatch = UA && isIos && /os ([\d_]+)/.test(UA) +const iosVersionMatch = UA && isIos && UA.match(/os ([\d_]+)/) const iosVersion = iosVersionMatch && iosVersionMatch[1].split('_') // MutationObserver is unreliable in iOS 9.3 UIWebView