@vue/compiler-sfc 2.7.0-beta.8 → 2.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -329,7 +329,7 @@ function hasChanged(x, y) {
329
329
  return x === 0 && 1 / x !== 1 / y;
330
330
  }
331
331
  else {
332
- return x === x && y === y;
332
+ return x === x || y === y;
333
333
  }
334
334
  }
335
335
 
@@ -646,6 +646,7 @@ const DEFAULT_FILENAME = 'anonymous.vue';
646
646
  const splitRE$1 = /\r?\n/g;
647
647
  const replaceRE = /./g;
648
648
  const isSpecialTag = makeMap('script,style,template', true);
649
+ const isNeedIndentLang = makeMap('pug,jade');
649
650
  /**
650
651
  * Parse a single-file component (*.vue) file into an SFC Descriptor Object.
651
652
  */
@@ -740,7 +741,9 @@ function parseComponent(source, options = {}) {
740
741
  if (depth === 1 && currentBlock) {
741
742
  currentBlock.end = start;
742
743
  let text = source.slice(currentBlock.start, currentBlock.end);
743
- if (options.deindent) {
744
+ if (options.deindent ||
745
+ // certain langs like pug are indent sensitive, preserve old behavior
746
+ (currentBlock.lang && isNeedIndentLang(currentBlock.lang))) {
744
747
  text = deIndent(text);
745
748
  }
746
749
  // pad content so that linters and pre-processors can output correct
@@ -5319,7 +5322,7 @@ function defineReactive(obj, key, val, customSetter, shallow) {
5319
5322
  }
5320
5323
  }
5321
5324
  }
5322
- return isRef(value) ? value.value : value;
5325
+ return isRef(value) && !shallow ? value.value : value;
5323
5326
  },
5324
5327
  set: function reactiveSetter(newVal) {
5325
5328
  const value = getter ? getter.call(obj) : val;
@@ -8264,8 +8267,12 @@ function compileScript(sfc, options = { id: '' }) {
8264
8267
  }
8265
8268
  if (options.babelParserPlugins)
8266
8269
  plugins.push(...options.babelParserPlugins);
8267
- if (isTS)
8268
- plugins.push('typescript', 'decorators-legacy');
8270
+ if (isTS) {
8271
+ plugins.push('typescript');
8272
+ if (!plugins.includes('decorators')) {
8273
+ plugins.push('decorators-legacy');
8274
+ }
8275
+ }
8269
8276
  if (!scriptSetup) {
8270
8277
  if (!script) {
8271
8278
  throw new Error(`[@vue/compiler-sfc] SFC contains no <script> tags.`);
@@ -8356,18 +8363,14 @@ function compileScript(sfc, options = { id: '' }) {
8356
8363
  function error(msg, node, end = node.end + startOffset) {
8357
8364
  throw new Error(`[@vue/compiler-sfc] ${msg}\n\n${filename}\n${generateCodeFrame(source, node.start + startOffset, end)}`);
8358
8365
  }
8359
- function registerUserImport(source, local, imported, isType, isFromSetup, needTemplateUsageCheck) {
8366
+ function registerUserImport(source, local, imported, isType, isFromSetup) {
8360
8367
  if (source === 'vue' && imported) {
8361
8368
  userImportAlias[imported] = local;
8362
8369
  }
8363
8370
  // template usage check is only needed in non-inline mode, so we can skip
8364
8371
  // the work if inlineTemplate is true.
8365
- let isUsedInTemplate = needTemplateUsageCheck;
8366
- if (needTemplateUsageCheck &&
8367
- isTS &&
8368
- sfc.template &&
8369
- !sfc.template.src &&
8370
- !sfc.template.lang) {
8372
+ let isUsedInTemplate = true;
8373
+ if (isTS && sfc.template && !sfc.template.src && !sfc.template.lang) {
8371
8374
  isUsedInTemplate = isImportUsed(local, sfc);
8372
8375
  }
8373
8376
  userImports[local] = {
@@ -8618,7 +8621,7 @@ function compileScript(sfc, options = { id: '' }) {
8618
8621
  specifier.imported.name;
8619
8622
  registerUserImport(node.source.value, specifier.local.name, imported, node.importKind === 'type' ||
8620
8623
  (specifier.type === 'ImportSpecifier' &&
8621
- specifier.importKind === 'type'), false, true);
8624
+ specifier.importKind === 'type'), false);
8622
8625
  }
8623
8626
  }
8624
8627
  else if (node.type === 'ExportDefaultDeclaration') {
@@ -8787,7 +8790,7 @@ function compileScript(sfc, options = { id: '' }) {
8787
8790
  else {
8788
8791
  registerUserImport(source, local, imported, node.importKind === 'type' ||
8789
8792
  (specifier.type === 'ImportSpecifier' &&
8790
- specifier.importKind === 'type'), true, true);
8793
+ specifier.importKind === 'type'), true);
8791
8794
  }
8792
8795
  }
8793
8796
  if (node.specifiers.length && removed === node.specifiers.length) {
@@ -9522,7 +9525,11 @@ function resolveTemplateUsageCheckString(sfc) {
9522
9525
  for (let i = 0; i < attrs.length; i++) {
9523
9526
  const { name, value } = attrs[i];
9524
9527
  if (dirRE.test(name)) {
9525
- const baseName = name.replace(dirRE, '');
9528
+ const baseName = onRE.test(name)
9529
+ ? 'on'
9530
+ : bindRE.test(name)
9531
+ ? 'bind'
9532
+ : name.replace(dirRE, '');
9526
9533
  if (!isBuiltInDir$1(baseName)) {
9527
9534
  code += `,v${capitalize(camelize(baseName))}`;
9528
9535
  }
@@ -9548,6 +9555,9 @@ function processExp(exp, dir) {
9548
9555
  if (dir === 'slot') {
9549
9556
  exp = `(${exp})=>{}`;
9550
9557
  }
9558
+ else if (dir === 'on') {
9559
+ exp = `()=>{${exp}}`;
9560
+ }
9551
9561
  else if (dir === 'for') {
9552
9562
  const inMatch = exp.match(forAliasRE);
9553
9563
  if (inMatch) {
@@ -9803,7 +9813,7 @@ function transform(node, transformAssetUrlsOptions) {
9803
9813
  return;
9804
9814
  }
9805
9815
  const imageCandidates = value
9806
- .substr(1, value.length - 2)
9816
+ .slice(1, -1)
9807
9817
  .split(',')
9808
9818
  .map(s => {
9809
9819
  // The attribute value arrives here with all whitespace, except
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/compiler-sfc",
3
- "version": "2.7.0-beta.8",
3
+ "version": "2.7.2",
4
4
  "description": "compiler-sfc for Vue 2",
5
5
  "main": "dist/compiler-sfc.js",
6
6
  "types": "dist/compiler-sfc.d.ts",