|
1 | 1 | /*! |
2 | | - * Vue.js v1.0.11 |
| 2 | + * Vue.js v1.0.12 |
3 | 3 | * (c) 2015 Evan You |
4 | 4 | * Released under the MIT License. |
5 | 5 | */ |
|
1253 | 1253 |
|
1254 | 1254 | function setClass(el, cls) { |
1255 | 1255 | /* istanbul ignore if */ |
1256 | | - if (isIE9 && el.hasOwnProperty('className')) { |
| 1256 | + if (isIE9 && !(el instanceof SVGElement)) { |
1257 | 1257 | el.className = cls; |
1258 | 1258 | } else { |
1259 | 1259 | el.setAttribute('class', cls); |
|
1454 | 1454 | } |
1455 | 1455 |
|
1456 | 1456 | var commonTagRE = /^(div|p|span|img|a|b|i|br|ul|ol|li|h1|h2|h3|h4|h5|h6|code|pre|table|th|td|tr|form|label|input|select|option|nav|article|section|header|footer)$/; |
| 1457 | + var reservedTagRE = /^(slot|partial|component)$/; |
1457 | 1458 |
|
1458 | 1459 | /** |
1459 | 1460 | * Check if an element is a component, if yes return its |
|
1467 | 1468 | function checkComponentAttr(el, options) { |
1468 | 1469 | var tag = el.tagName.toLowerCase(); |
1469 | 1470 | var hasAttrs = el.hasAttributes(); |
1470 | | - if (!commonTagRE.test(tag) && tag !== 'component') { |
| 1471 | + if (!commonTagRE.test(tag) && !reservedTagRE.test(tag)) { |
1471 | 1472 | if (resolveAsset(options, 'components', tag)) { |
1472 | 1473 | return { id: tag }; |
1473 | 1474 | } else { |
|
1518 | 1519 |
|
1519 | 1520 | function initProp(vm, prop, value) { |
1520 | 1521 | var key = prop.path; |
| 1522 | + value = coerceProp(prop, value); |
1521 | 1523 | vm[key] = vm._data[key] = assertProp(prop, value) ? value : undefined; |
1522 | 1524 | } |
1523 | 1525 |
|
|
1575 | 1577 | return true; |
1576 | 1578 | } |
1577 | 1579 |
|
| 1580 | + /** |
| 1581 | + * Force parsing value with coerce option. |
| 1582 | + * |
| 1583 | + * @param {*} value |
| 1584 | + * @param {Object} options |
| 1585 | + * @return {*} |
| 1586 | + */ |
| 1587 | + |
| 1588 | + function coerceProp(prop, value) { |
| 1589 | + var coerce = prop.options.coerce; |
| 1590 | + if (!coerce) { |
| 1591 | + return value; |
| 1592 | + } |
| 1593 | + // coerce is a function |
| 1594 | + return coerce(value); |
| 1595 | + } |
| 1596 | + |
1578 | 1597 | function formatType(val) { |
1579 | 1598 | return val ? val.charAt(0).toUpperCase() + val.slice(1) : 'custom type'; |
1580 | 1599 | } |
|
1760 | 1779 | var ids = Object.keys(components); |
1761 | 1780 | for (var i = 0, l = ids.length; i < l; i++) { |
1762 | 1781 | var key = ids[i]; |
1763 | | - if (commonTagRE.test(key)) { |
1764 | | - 'development' !== 'production' && warn('Do not use built-in HTML elements as component ' + 'id: ' + key); |
| 1782 | + if (commonTagRE.test(key) || reservedTagRE.test(key)) { |
| 1783 | + 'development' !== 'production' && warn('Do not use built-in or reserved HTML elements as component ' + 'id: ' + key); |
1765 | 1784 | continue; |
1766 | 1785 | } |
1767 | 1786 | def = components[key]; |
|
2281 | 2300 | replace: replace, |
2282 | 2301 | on: on$1, |
2283 | 2302 | off: off, |
| 2303 | + setClass: setClass, |
2284 | 2304 | addClass: addClass, |
2285 | 2305 | removeClass: removeClass, |
2286 | 2306 | extractContent: extractContent, |
|
2296 | 2316 | checkComponentAttr: checkComponentAttr, |
2297 | 2317 | initProp: initProp, |
2298 | 2318 | assertProp: assertProp, |
| 2319 | + coerceProp: coerceProp, |
2299 | 2320 | commonTagRE: commonTagRE, |
| 2321 | + reservedTagRE: reservedTagRE, |
2300 | 2322 | get warn () { return warn; } |
2301 | 2323 | }); |
2302 | 2324 |
|
|
3224 | 3246 | if (this.active) { |
3225 | 3247 | var value = this.get(); |
3226 | 3248 | if (value !== this.value || |
3227 | | - // Deep watchers and Array watchers should fire even |
| 3249 | + // Deep watchers and watchers on Object/Arrays should fire even |
3228 | 3250 | // when the value is the same, because the value may |
3229 | 3251 | // have mutated; but only do so if this is a |
3230 | 3252 | // non-shallow update (caused by a vm digest). |
3231 | | - (isArray(value) || this.deep) && !this.shallow) { |
| 3253 | + (isObject(value) || this.deep) && !this.shallow) { |
3232 | 3254 | // set new value |
3233 | 3255 | var oldValue = this.value; |
3234 | 3256 | this.value = value; |
|
3474 | 3496 | var xlinkNS = 'http://www.w3.org/1999/xlink'; |
3475 | 3497 | var xlinkRE = /^xlink:/; |
3476 | 3498 |
|
3477 | | - // these input element attributes should also set their |
3478 | | - // corresponding properties |
3479 | | - var inputProps = { |
3480 | | - value: 1, |
3481 | | - checked: 1, |
3482 | | - selected: 1 |
3483 | | - }; |
| 3499 | + // check for attributes that prohibit interpolations |
| 3500 | + var disallowedInterpAttrRE = /^v-|^:|^@|^(is|transition|transition-mode|debounce|track-by|stagger|enter-stagger|leave-stagger)$/; |
| 3501 | + |
| 3502 | + // these attributes should also set their corresponding properties |
| 3503 | + // because they only affect the initial state of the element |
| 3504 | + var attrWithPropsRE = /^(value|checked|selected|muted)$/; |
3484 | 3505 |
|
3485 | 3506 | // these attributes should set a hidden property for |
3486 | 3507 | // binding v-model to object values |
|
3490 | 3511 | 'false-value': '_falseValue' |
3491 | 3512 | }; |
3492 | 3513 |
|
3493 | | - // check for attributes that prohibit interpolations |
3494 | | - var disallowedInterpAttrRE = /^v-|^:|^@|^(is|transition|transition-mode|debounce|track-by|stagger|enter-stagger|leave-stagger)$/; |
3495 | | - |
3496 | 3514 | var bind = { |
3497 | 3515 |
|
3498 | 3516 | priority: 850, |
|
3545 | 3563 | handleObject: style.handleObject, |
3546 | 3564 |
|
3547 | 3565 | handleSingle: function handleSingle(attr, value) { |
3548 | | - if (inputProps[attr] && attr in this.el) { |
3549 | | - this.el[attr] = attr === 'value' ? value || '' : // IE9 will set input.value to "null" for null... |
3550 | | - value; |
| 3566 | + if (!this.descriptor.interp && attrWithPropsRE.test(attr) && attr in this.el) { |
| 3567 | + this.el[attr] = attr === 'value' ? value == null // IE9 will set input.value to "null" for null... |
| 3568 | + ? '' : value : value; |
3551 | 3569 | } |
3552 | 3570 | // set model props |
3553 | 3571 | var modelProp = modelProps[attr]; |
|
3928 | 3946 | }); |
3929 | 3947 | this.on('blur', function () { |
3930 | 3948 | self.focused = false; |
3931 | | - self.listener(); |
| 3949 | + // do not sync value after fragment removal (#2017) |
| 3950 | + if (!self._frag || self._frag.inserted) { |
| 3951 | + self.rawListener(); |
| 3952 | + } |
3932 | 3953 | }); |
3933 | 3954 | } |
3934 | 3955 |
|
3935 | 3956 | // Now attach the main listener |
3936 | | - this.listener = function () { |
3937 | | - if (composing) return; |
| 3957 | + this.listener = this.rawListener = function () { |
| 3958 | + if (composing || !self._bound) { |
| 3959 | + return; |
| 3960 | + } |
3938 | 3961 | var val = number || isRange ? toNumber(el.value) : el.value; |
3939 | 3962 | self.set(val); |
3940 | 3963 | // force update on next tick to avoid lock & same value |
|
4098 | 4121 | }, |
4099 | 4122 |
|
4100 | 4123 | apply: function apply(el, value) { |
4101 | | - applyTransition(el, value ? 1 : -1, function () { |
| 4124 | + if (inDoc(el)) { |
| 4125 | + applyTransition(el, value ? 1 : -1, toggle, this.vm); |
| 4126 | + } else { |
| 4127 | + toggle(); |
| 4128 | + } |
| 4129 | + function toggle() { |
4102 | 4130 | el.style.display = value ? '' : 'none'; |
4103 | | - }, this.vm); |
| 4131 | + } |
4104 | 4132 | } |
4105 | 4133 | }; |
4106 | 4134 |
|
|
4135 | 4163 | } |
4136 | 4164 |
|
4137 | 4165 | var tagRE$1 = /<([\w:]+)/; |
4138 | | - var entityRE = /&\w+;|&#\d+;|&#x[\dA-F]+;/; |
| 4166 | + var entityRE = /&#?\w+?;/; |
4139 | 4167 |
|
4140 | 4168 | /** |
4141 | 4169 | * Convert a string template to a DocumentFragment. |
|
5670 | 5698 | var twoWay = prop.mode === bindingModes.TWO_WAY; |
5671 | 5699 |
|
5672 | 5700 | var parentWatcher = this.parentWatcher = new Watcher(parent, parentKey, function (val) { |
| 5701 | + val = coerceProp(prop, val); |
5673 | 5702 | if (assertProp(prop, val)) { |
5674 | 5703 | child[childKey] = val; |
5675 | 5704 | } |
|
7652 | 7681 | } else { |
7653 | 7682 | // for class interpolations, only remove the parts that |
7654 | 7683 | // need to be interpolated. |
7655 | | - this.el.className = removeTags(this.el.className).trim().replace(/\s+/g, ' '); |
| 7684 | + setClass(this.el, removeTags(this.el.getAttribute('class')).trim().replace(/\s+/g, ' ')); |
7656 | 7685 | } |
7657 | 7686 | } |
7658 | 7687 |
|
|
7671 | 7700 | if (this.bind) { |
7672 | 7701 | this.bind(); |
7673 | 7702 | } |
| 7703 | + this._bound = true; |
7674 | 7704 |
|
7675 | 7705 | if (this.literal) { |
7676 | 7706 | this.update && this.update(descriptor.raw); |
|
7706 | 7736 | this.update(watcher.value); |
7707 | 7737 | } |
7708 | 7738 | } |
7709 | | - this._bound = true; |
7710 | 7739 | }; |
7711 | 7740 |
|
7712 | 7741 | /** |
|
7927 | 7956 | el = transclude(el, options); |
7928 | 7957 | this._initElement(el); |
7929 | 7958 |
|
| 7959 | + // handle v-pre on root node (#2026) |
| 7960 | + if (el.nodeType === 1 && getAttr(el, 'v-pre') !== null) { |
| 7961 | + return; |
| 7962 | + } |
| 7963 | + |
7930 | 7964 | // root is always compiled per-instance, because |
7931 | 7965 | // container attrs and props can be different every time. |
7932 | 7966 | var contextOptions = this._context && this._context.$options; |
|
8354 | 8388 | } else { |
8355 | 8389 | /* istanbul ignore if */ |
8356 | 8390 | if ('development' !== 'production') { |
8357 | | - if (type === 'component' && commonTagRE.test(id)) { |
8358 | | - warn('Do not use built-in HTML elements as component ' + 'id: ' + id); |
| 8391 | + if (type === 'component' && (commonTagRE.test(id) || reservedTagRE.test(id))) { |
| 8392 | + warn('Do not use built-in or reserved HTML elements as component ' + 'id: ' + id); |
8359 | 8393 | } |
8360 | 8394 | } |
8361 | 8395 | if (type === 'component' && isPlainObject(definition)) { |
|
9367 | 9401 | partial: partial |
9368 | 9402 | }; |
9369 | 9403 |
|
9370 | | - Vue.version = '1.0.11'; |
| 9404 | + Vue.version = '1.0.12'; |
9371 | 9405 |
|
9372 | 9406 | /** |
9373 | 9407 | * Vue and every constructor that extends Vue has an |
|
0 commit comments