|
|
@@ -388,7 +388,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 {
|
|
|
@@ -1913,19 +1913,19 @@ function renderMixin(Vue) {
|
|
|
if (Array.isArray(val)) {
|
|
|
ret = new Array(val.length);
|
|
|
for (i = 0, l = val.length; i < l; i++) {
|
|
|
- ret[i] = render(val[i], i, i);
|
|
|
+ ret[i] = render(val[i], i);
|
|
|
}
|
|
|
} else if (typeof val === 'number') {
|
|
|
ret = new Array(val);
|
|
|
for (i = 0; i < val; i++) {
|
|
|
- ret[i] = render(i + 1, i, i);
|
|
|
+ ret[i] = render(i + 1, i);
|
|
|
}
|
|
|
} else if (isObject(val)) {
|
|
|
keys = Object.keys(val);
|
|
|
ret = new Array(keys.length);
|
|
|
for (i = 0, l = keys.length; i < l; i++) {
|
|
|
key = keys[i];
|
|
|
- ret[i] = render(val[key], i, key);
|
|
|
+ ret[i] = render(val[key], key, i);
|
|
|
}
|
|
|
}
|
|
|
return ret;
|
|
|
@@ -2104,7 +2104,7 @@ function initInternalComponent(vm, options) {
|
|
|
opts._componentTag = options._componentTag;
|
|
|
if (options.render) {
|
|
|
opts.render = options.render;
|
|
|
- opts.staticRenderFns = opts.staticRenderFns;
|
|
|
+ opts.staticRenderFns = options.staticRenderFns;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -2578,7 +2578,7 @@ var IS_REGEX_CAPTURING_BROKEN = false;
|
|
|
});
|
|
|
|
|
|
// Special Elements (can contain anything)
|
|
|
-var special = makeMap('script,style', true);
|
|
|
+var isSpecialTag = makeMap('script,style', true);
|
|
|
|
|
|
var reCache = {};
|
|
|
|
|
|
@@ -2598,10 +2598,8 @@ function parseHTML(html, handler) {
|
|
|
var attribute = attrForHandler(handler);
|
|
|
var expectHTML = handler.expectHTML;
|
|
|
var isUnaryTag = handler.isUnaryTag || no;
|
|
|
- var isSpecialTag = handler.isSpecialTag || special;
|
|
|
+ var index = 0;
|
|
|
var last = void 0,
|
|
|
- prevTag = void 0,
|
|
|
- nextTag = void 0,
|
|
|
lastTag = void 0;
|
|
|
while (html) {
|
|
|
last = html;
|
|
|
@@ -2614,8 +2612,7 @@ function parseHTML(html, handler) {
|
|
|
var commentEnd = html.indexOf('-->');
|
|
|
|
|
|
if (commentEnd >= 0) {
|
|
|
- html = html.substring(commentEnd + 3);
|
|
|
- prevTag = '';
|
|
|
+ advance(commentEnd + 3);
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
@@ -2625,8 +2622,7 @@ function parseHTML(html, handler) {
|
|
|
var conditionalEnd = html.indexOf(']>');
|
|
|
|
|
|
if (conditionalEnd >= 0) {
|
|
|
- html = html.substring(conditionalEnd + 2);
|
|
|
- prevTag = '';
|
|
|
+ advance(conditionalEnd + 2);
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
@@ -2637,26 +2633,23 @@ function parseHTML(html, handler) {
|
|
|
if (handler.doctype) {
|
|
|
handler.doctype(doctypeMatch[0]);
|
|
|
}
|
|
|
- html = html.substring(doctypeMatch[0].length);
|
|
|
- prevTag = '';
|
|
|
+ advance(doctypeMatch[0].length);
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
// End tag:
|
|
|
var endTagMatch = html.match(endTag);
|
|
|
if (endTagMatch) {
|
|
|
- html = html.substring(endTagMatch[0].length);
|
|
|
- endTagMatch[0].replace(endTag, parseEndTag);
|
|
|
- prevTag = '/' + endTagMatch[1].toLowerCase();
|
|
|
+ var curIndex = index;
|
|
|
+ advance(endTagMatch[0].length);
|
|
|
+ parseEndTag(endTagMatch[0], endTagMatch[1], curIndex, index);
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
// Start tag:
|
|
|
- var startTagMatch = parseStartTag(html);
|
|
|
+ var startTagMatch = parseStartTag();
|
|
|
if (startTagMatch) {
|
|
|
- html = startTagMatch.rest;
|
|
|
handleStartTag(startTagMatch);
|
|
|
- prevTag = startTagMatch.tagName.toLowerCase();
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
@@ -2664,35 +2657,22 @@ function parseHTML(html, handler) {
|
|
|
var text = void 0;
|
|
|
if (textEnd >= 0) {
|
|
|
text = html.substring(0, textEnd);
|
|
|
- html = html.substring(textEnd);
|
|
|
+ advance(textEnd);
|
|
|
} else {
|
|
|
text = html;
|
|
|
html = '';
|
|
|
}
|
|
|
|
|
|
- // next tag
|
|
|
- var nextTagMatch = parseStartTag(html);
|
|
|
- if (nextTagMatch) {
|
|
|
- nextTag = nextTagMatch.tagName;
|
|
|
- } else {
|
|
|
- nextTagMatch = html.match(endTag);
|
|
|
- if (nextTagMatch) {
|
|
|
- nextTag = '/' + nextTagMatch[1];
|
|
|
- } else {
|
|
|
- nextTag = '';
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
if (handler.chars) {
|
|
|
- handler.chars(text, prevTag, nextTag);
|
|
|
+ handler.chars(text);
|
|
|
}
|
|
|
- prevTag = '';
|
|
|
} else {
|
|
|
(function () {
|
|
|
var stackedTag = lastTag.toLowerCase();
|
|
|
- var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)</' + stackedTag + '[^>]*>', 'i'));
|
|
|
-
|
|
|
- html = html.replace(reStackedTag, function (all, text) {
|
|
|
+ var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
|
|
|
+ var endTagLength = 0;
|
|
|
+ var rest = html.replace(reStackedTag, function (all, text, endTag) {
|
|
|
+ endTagLength = endTag.length;
|
|
|
if (stackedTag !== 'script' && stackedTag !== 'style' && stackedTag !== 'noscript') {
|
|
|
text = text.replace(/<!--([\s\S]*?)-->/g, '$1').replace(/<!\[CDATA\[([\s\S]*?)\]\]>/g, '$1');
|
|
|
}
|
|
|
@@ -2701,8 +2681,9 @@ function parseHTML(html, handler) {
|
|
|
}
|
|
|
return '';
|
|
|
});
|
|
|
-
|
|
|
- parseEndTag('</' + stackedTag + '>', stackedTag);
|
|
|
+ index += html.length - rest.length;
|
|
|
+ html = rest;
|
|
|
+ parseEndTag('</' + stackedTag + '>', stackedTag, index - endTagLength, index);
|
|
|
})();
|
|
|
}
|
|
|
|
|
|
@@ -2711,28 +2692,33 @@ function parseHTML(html, handler) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (!handler.partialMarkup) {
|
|
|
- // Clean up any remaining tags
|
|
|
- parseEndTag();
|
|
|
+ // Clean up any remaining tags
|
|
|
+ parseEndTag();
|
|
|
+
|
|
|
+ function advance(n) {
|
|
|
+ index += n;
|
|
|
+ html = html.substring(n);
|
|
|
}
|
|
|
|
|
|
- function parseStartTag(input) {
|
|
|
- var start = input.match(startTagOpen);
|
|
|
+ function parseStartTag() {
|
|
|
+ var start = html.match(startTagOpen);
|
|
|
if (start) {
|
|
|
var match = {
|
|
|
tagName: start[1],
|
|
|
- attrs: []
|
|
|
+ attrs: [],
|
|
|
+ start: index
|
|
|
};
|
|
|
- input = input.slice(start[0].length);
|
|
|
+ advance(start[0].length);
|
|
|
var end = void 0,
|
|
|
attr = void 0;
|
|
|
- while (!(end = input.match(startTagClose)) && (attr = input.match(attribute))) {
|
|
|
- input = input.slice(attr[0].length);
|
|
|
+ while (!(end = html.match(startTagClose)) && (attr = html.match(attribute))) {
|
|
|
+ advance(attr[0].length);
|
|
|
match.attrs.push(attr);
|
|
|
}
|
|
|
if (end) {
|
|
|
match.unarySlash = end[1];
|
|
|
- match.rest = input.slice(end[0].length);
|
|
|
+ advance(end[0].length);
|
|
|
+ match.end = index;
|
|
|
return match;
|
|
|
}
|
|
|
}
|
|
|
@@ -2782,12 +2768,14 @@ function parseHTML(html, handler) {
|
|
|
}
|
|
|
|
|
|
if (handler.start) {
|
|
|
- handler.start(tagName, attrs, unary, unarySlash);
|
|
|
+ handler.start(tagName, attrs, unary, match.start, match.end);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- function parseEndTag(tag, tagName) {
|
|
|
+ function parseEndTag(tag, tagName, start, end) {
|
|
|
var pos = void 0;
|
|
|
+ if (start == null) start = index;
|
|
|
+ if (end == null) end = index;
|
|
|
|
|
|
// Find the closest opened tag of the same type
|
|
|
if (tagName) {
|
|
|
@@ -2806,7 +2794,7 @@ function parseHTML(html, handler) {
|
|
|
// Close all the open elements, up the stack
|
|
|
for (var i = stack.length - 1; i >= pos; i--) {
|
|
|
if (handler.end) {
|
|
|
- handler.end(stack[i].tag, stack[i].attrs, i > pos || !tag);
|
|
|
+ handler.end(stack[i].tag, start, end);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -2815,14 +2803,14 @@ function parseHTML(html, handler) {
|
|
|
lastTag = pos && stack[pos - 1].tag;
|
|
|
} else if (tagName.toLowerCase() === 'br') {
|
|
|
if (handler.start) {
|
|
|
- handler.start(tagName, [], true, '');
|
|
|
+ handler.start(tagName, [], true, start, end);
|
|
|
}
|
|
|
} else if (tagName.toLowerCase() === 'p') {
|
|
|
if (handler.start) {
|
|
|
- handler.start(tagName, [], false, '', true);
|
|
|
+ handler.start(tagName, [], false, start, end);
|
|
|
}
|
|
|
if (handler.end) {
|
|
|
- handler.end(tagName, []);
|
|
|
+ handler.end(tagName, start, end);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -3038,7 +3026,7 @@ var onRE = /^@|^v-on:/;
|
|
|
var argRE = /:(.*)$/;
|
|
|
var modifierRE = /\.[^\.]+/g;
|
|
|
var forAliasRE = /(.*)\s+(?:in|of)\s+(.*)/;
|
|
|
-var forIteratorRE = /\((.*),(.*)\)/;
|
|
|
+var forIteratorRE = /\(([^,]*),([^,]*)(?:,([^,]*))?\)/;
|
|
|
var camelRE = /[a-z\d][A-Z]/;
|
|
|
|
|
|
var decodeHTMLCached = cached(entities.decodeHTML);
|
|
|
@@ -3257,8 +3245,11 @@ function processFor(el) {
|
|
|
var alias = inMatch[1].trim();
|
|
|
var iteratorMatch = alias.match(forIteratorRE);
|
|
|
if (iteratorMatch) {
|
|
|
- el.iterator = iteratorMatch[1].trim();
|
|
|
- el.alias = iteratorMatch[2].trim();
|
|
|
+ el.alias = iteratorMatch[1].trim();
|
|
|
+ el.iterator1 = iteratorMatch[2].trim();
|
|
|
+ if (iteratorMatch[3]) {
|
|
|
+ el.iterator2 = iteratorMatch[3].trim();
|
|
|
+ }
|
|
|
} else {
|
|
|
el.alias = alias;
|
|
|
}
|
|
|
@@ -3678,9 +3669,10 @@ function genElse(el) {
|
|
|
function genFor(el) {
|
|
|
var exp = el.for;
|
|
|
var alias = el.alias;
|
|
|
- var iterator = el.iterator;
|
|
|
+ var iterator1 = el.iterator1 ? ',' + el.iterator1 : '';
|
|
|
+ var iterator2 = el.iterator2 ? ',' + el.iterator2 : '';
|
|
|
el.for = null; // avoid recursion
|
|
|
- return '(' + exp + ')&&_l((' + exp + '),' + ('function(' + alias + ',$index,' + (iterator || '$key') + '){') + ('return ' + genElement(el)) + '})';
|
|
|
+ return '(' + exp + ')&&_l((' + exp + '),' + ('function(' + alias + iterator1 + iterator2 + '){') + ('return ' + genElement(el)) + '})';
|
|
|
}
|
|
|
|
|
|
function genData(el) {
|
|
|
@@ -4161,7 +4153,7 @@ function makeFunction(code) {
|
|
|
|
|
|
var splitRE = /\r?\n/g;
|
|
|
var emptyRE = /^(?:\/\/)?\s*$/;
|
|
|
-var isSpecialTag = makeMap('script,style,template', true);
|
|
|
+var isSpecialTag$1 = makeMap('script,style,template', true);
|
|
|
|
|
|
/**
|
|
|
* Parse a single-file component (*.vue) file into an SFC Descriptor Object.
|
|
|
@@ -4177,15 +4169,12 @@ function parseComponent(content) {
|
|
|
var depth = 0;
|
|
|
var currentBlock = null;
|
|
|
|
|
|
- function start(tag, attrs) {
|
|
|
- depth++;
|
|
|
- if (depth > 1) {
|
|
|
- return;
|
|
|
- }
|
|
|
- if (isSpecialTag(tag)) {
|
|
|
+ function start(tag, attrs, unary, start, end) {
|
|
|
+ if (isSpecialTag$1(tag) && depth === 0) {
|
|
|
currentBlock = {
|
|
|
type: tag,
|
|
|
- content: ''
|
|
|
+ content: '',
|
|
|
+ start: end
|
|
|
};
|
|
|
checkAttrs(currentBlock, attrs);
|
|
|
if (tag === 'style') {
|
|
|
@@ -4194,6 +4183,7 @@ function parseComponent(content) {
|
|
|
sfc[tag] = currentBlock;
|
|
|
}
|
|
|
}
|
|
|
+ depth++;
|
|
|
}
|
|
|
|
|
|
function checkAttrs(block, attrs) {
|
|
|
@@ -4211,26 +4201,22 @@ function parseComponent(content) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- function end() {
|
|
|
- depth--;
|
|
|
- if (options.map && currentBlock && !currentBlock.src) {
|
|
|
- addSourceMap(currentBlock);
|
|
|
- }
|
|
|
- currentBlock = null;
|
|
|
- }
|
|
|
-
|
|
|
- function chars(text) {
|
|
|
- if (currentBlock) {
|
|
|
- currentBlock.start = content.indexOf(text);
|
|
|
- currentBlock.end = currentBlock.start + text.length;
|
|
|
- text = deindent(text);
|
|
|
+ function end(tag, start, end) {
|
|
|
+ if (isSpecialTag$1(tag) && depth === 1 && currentBlock) {
|
|
|
+ currentBlock.end = start;
|
|
|
+ var text = deindent(content.slice(currentBlock.start, currentBlock.end));
|
|
|
// pad content so that linters and pre-processors can output correct
|
|
|
// line numbers in errors and warnings
|
|
|
if (currentBlock.type !== 'template' && options.pad) {
|
|
|
text = padContent(currentBlock) + text;
|
|
|
}
|
|
|
currentBlock.content = text;
|
|
|
+ if (options.map && !currentBlock.src) {
|
|
|
+ addSourceMap(currentBlock);
|
|
|
+ }
|
|
|
+ currentBlock = null;
|
|
|
}
|
|
|
+ depth--;
|
|
|
}
|
|
|
|
|
|
function padContent(block) {
|
|
|
@@ -4270,10 +4256,8 @@ function parseComponent(content) {
|
|
|
}
|
|
|
|
|
|
parseHTML(content, {
|
|
|
- isSpecialTag: isSpecialTag,
|
|
|
start: start,
|
|
|
- end: end,
|
|
|
- chars: chars
|
|
|
+ end: end
|
|
|
});
|
|
|
|
|
|
return sfc;
|