mirror of https://github.com/vuejs/core.git
wip: comments
This commit is contained in:
parent
a12abe72bc
commit
5a855c57d7
|
@ -157,8 +157,8 @@ export interface Callbacks {
|
|||
ondirarg(start: number, endIndex: number): void
|
||||
ondirmodifier(start: number, endIndex: number): void
|
||||
|
||||
oncomment(start: number, endIndex: number, endOffset: number): void
|
||||
oncdata(start: number, endIndex: number, endOffset: number): void
|
||||
oncomment(start: number, endIndex: number): void
|
||||
oncdata(start: number, endIndex: number): void
|
||||
|
||||
// onprocessinginstruction(start: number, endIndex: number): void
|
||||
// ondeclaration(start: number, endIndex: number): void
|
||||
|
@ -400,9 +400,9 @@ export default class Tokenizer {
|
|||
if (c === this.currentSequence[this.sequenceIndex]) {
|
||||
if (++this.sequenceIndex === this.currentSequence.length) {
|
||||
if (this.currentSequence === Sequences.CdataEnd) {
|
||||
this.cbs.oncdata(this.sectionStart, this.index, 2)
|
||||
this.cbs.oncdata(this.sectionStart, this.index - 2)
|
||||
} else {
|
||||
this.cbs.oncomment(this.sectionStart, this.index, 2)
|
||||
this.cbs.oncomment(this.sectionStart, this.index - 2)
|
||||
}
|
||||
|
||||
this.sequenceIndex = 0
|
||||
|
@ -691,7 +691,7 @@ export default class Tokenizer {
|
|||
}
|
||||
private stateInSpecialComment(c: number): void {
|
||||
if (c === CharCodes.Gt || this.fastForwardTo(CharCodes.Gt)) {
|
||||
this.cbs.oncomment(this.sectionStart, this.index, 0)
|
||||
this.cbs.oncomment(this.sectionStart, this.index)
|
||||
this.state = State.Text
|
||||
this.sectionStart = this.index + 1
|
||||
}
|
||||
|
@ -920,9 +920,9 @@ export default class Tokenizer {
|
|||
|
||||
if (this.state === State.InCommentLike) {
|
||||
if (this.currentSequence === Sequences.CdataEnd) {
|
||||
this.cbs.oncdata(this.sectionStart, endIndex, 0)
|
||||
this.cbs.oncdata(this.sectionStart, endIndex)
|
||||
} else {
|
||||
this.cbs.oncomment(this.sectionStart, endIndex, 0)
|
||||
this.cbs.oncomment(this.sectionStart, endIndex)
|
||||
}
|
||||
} else if (
|
||||
this.state === State.InTagName ||
|
||||
|
|
|
@ -291,8 +291,14 @@ const tokenizer = new Tokenizer({
|
|||
currentAttrStartIndex = currentAttrEndIndex = -1
|
||||
},
|
||||
|
||||
oncomment(start, end, offset) {
|
||||
// TODO oncomment
|
||||
oncomment(start, end) {
|
||||
if (currentOptions.comments) {
|
||||
addNode({
|
||||
type: NodeTypes.COMMENT,
|
||||
content: getSlice(start, end),
|
||||
loc: getLoc(start - 4, end + 3)
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
onend() {
|
||||
|
@ -302,7 +308,7 @@ const tokenizer = new Tokenizer({
|
|||
}
|
||||
},
|
||||
|
||||
oncdata(start, end, offset) {
|
||||
oncdata(start, end) {
|
||||
// TODO throw error
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue