support vue 2.2 (#3097)

pull/3143/head
cinwell.li 2017-02-28 13:09:31 +08:00 committed by baiyaaaaa
parent 46fc121cb3
commit ce8c869292
5 changed files with 28 additions and 12 deletions

View File

@ -2,7 +2,7 @@
import { addResizeListener, removeResizeListener } from 'element-ui/src/utils/resize-event';
import scrollbarWidth from 'element-ui/src/utils/scrollbar-width';
import * as util from './util';
import { toObject } from 'element-ui/src/utils/util';
import Bar from './bar';
/* istanbul ignore next */
@ -48,7 +48,7 @@ export default {
const gutterStyle = `margin-bottom: ${gutterWith}; margin-right: ${gutterWith};`;
if (Array.isArray(this.wrapStyle)) {
style = util.toObject(this.wrapStyle);
style = toObject(this.wrapStyle);
style.marginRight = style.marginBottom = gutterWith;
} else if (typeof this.wrapStyle === 'string') {
style += gutterStyle;

View File

@ -1,5 +1,3 @@
import Vue from 'vue';
export const BAR_MAP = {
vertical: {
offset: 'offsetHeight',
@ -34,5 +32,3 @@ export function renderThumbStyle({ move, size, bar }) {
return style;
};
export const toObject = Vue.util.toObject;

View File

@ -1,13 +1,12 @@
import { hasOwn } from 'element-ui/src/utils/util';
const RE_NARGS = /(%|)\{([0-9a-zA-Z_]+)\}/g;
/**
* String format template
* - Inspired:
* https://github.com/Matt-Esch/string-template/index.js
*/
const RE_NARGS = /(%|)\{([0-9a-zA-Z_]+)\}/g;
export default function(Vue) {
const { hasOwn } = Vue.util;
/**
* template

21
src/utils/util.js Normal file
View File

@ -0,0 +1,21 @@
const hasOwnProperty = Object.prototype.hasOwnProperty;
export function hasOwn(obj, key) {
return hasOwnProperty.call(obj, key);
};
function extend(to, _from) {
for (let key in _from) {
to[key] = _from[key];
}
return to;
};
export function toObject(arr) {
var res = {};
for (let i = 0; i < arr.length; i++) {
if (arr[i]) {
extend(res, arr[i]);
}
}
return res;
};

View File

@ -1,7 +1,7 @@
import Vue from 'vue';
import { hasOwn } from 'element-ui/src/utils/util';
export function isVNode(node) {
return typeof node === 'object' && Vue.util.hasOwn(node, 'componentOptions');
return typeof node === 'object' && hasOwn(node, 'componentOptions');
};
export function getFirstComponentChild(children) {