]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
wip: modifiers
authorEvan You <yyx990803@gmail.com>
Wed, 15 Nov 2023 09:57:28 +0000 (17:57 +0800)
committerEvan You <yyx990803@gmail.com>
Sat, 25 Nov 2023 08:18:29 +0000 (16:18 +0800)
packages/compiler-core/src/parser/index.ts

index 84e2a7d7fdb3770f4cb36cd52fcd5b96699f30e2..da2e54477cbf6b500ceb8235ba0b93349c4a4206 100644 (file)
@@ -13,7 +13,7 @@ import {
   createRoot
 } from '../ast'
 import { ParserOptions } from '../options'
-import Tokenizer, { CharCodes, isWhitespace } from './Tokenizer'
+import Tokenizer, { CharCodes, QuoteType, isWhitespace } from './Tokenizer'
 import { CompilerCompatOptions } from '../compat/compatConfig'
 import { NO, extend } from '@vue/shared'
 import { defaultOnError, defaultOnWarn } from '../errors'
@@ -184,18 +184,18 @@ const tokenizer = new Tokenizer(
       }
     },
     ondirmodifier(start, end) {
-      // console.log('.' + getSlice(start, end))
+      ;(currentProp as DirectiveNode).modifiers.push(getSlice(start, end))
     },
 
     onattribdata(start, end) {
       currentAttrValue += getSlice(start, end)
-      if (currentAttrStartIndex < 0) currentAttrStartIndex = start - 1
-      currentAttrEndIndex = end + 1
+      if (currentAttrStartIndex < 0) currentAttrStartIndex = start
+      currentAttrEndIndex = end
     },
     onattribentity(codepoint) {
       currentAttrValue += fromCodePoint(codepoint)
     },
-    onattribend(_quote, end) {
+    onattribend(quote, end) {
       // TODO check duplicate
       // if (currentAttrs.has(name)) {
       //   // emit error DUPLICATE_ATTRIBUTE
@@ -209,7 +209,10 @@ const tokenizer = new Tokenizer(
             currentProp!.value = {
               type: NodeTypes.TEXT,
               content: currentAttrValue,
-              loc: getLoc(currentAttrStartIndex, currentAttrEndIndex)
+              loc:
+                quote === QuoteType.Unquoted
+                  ? getLoc(currentAttrStartIndex, currentAttrEndIndex)
+                  : getLoc(currentAttrStartIndex - 1, currentAttrEndIndex + 1)
             }
           } else {
             // directive