From: Evan You Date: Wed, 15 Nov 2023 09:57:28 +0000 (+0800) Subject: wip: modifiers X-Git-Tag: v3.4.0-alpha.2~59 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=65c0b31148003f67f5b0c5f3f6c29266d88daebe;p=thirdparty%2Fvuejs%2Fcore.git wip: modifiers --- diff --git a/packages/compiler-core/src/parser/index.ts b/packages/compiler-core/src/parser/index.ts index 84e2a7d7fd..da2e54477c 100644 --- a/packages/compiler-core/src/parser/index.ts +++ b/packages/compiler-core/src/parser/index.ts @@ -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