mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-01 09:26:37 +00:00
Add custom JSON serializers for tokens that include a type attribute
This commit is contained in:
parent
61dae35ebc
commit
26f2026cff
Notes:
Gabriel Wicke
2012-02-27 16:40:01 +00:00
|
@ -8,26 +8,63 @@ function TagTk( name, attribs ) {
|
|||
this.attribs = attribs || [];
|
||||
}
|
||||
|
||||
TagTk.prototype.toJSON = function () {
|
||||
return {
|
||||
type: 'TagTk',
|
||||
name: this.name,
|
||||
attribs: this.attribs
|
||||
};
|
||||
};
|
||||
|
||||
function EndTagTk( name, attribs ) {
|
||||
//this.type = 'ENDTAG';
|
||||
this.name = name;
|
||||
this.attribs = attribs || [];
|
||||
}
|
||||
EndTagTk.prototype.toJSON = function () {
|
||||
return {
|
||||
type: 'EndTagTk',
|
||||
name: this.name,
|
||||
attribs: this.attribs
|
||||
};
|
||||
};
|
||||
|
||||
function SelfclosingTagTk( name, attribs ) {
|
||||
//this.type = 'SELFCLOSINGTAG';
|
||||
this.name = name;
|
||||
this.attribs = attribs || [];
|
||||
}
|
||||
SelfclosingTagTk.prototype.toJSON = function () {
|
||||
return {
|
||||
type: 'SelfclosingTagTk',
|
||||
name: this.name,
|
||||
attribs: this.attribs
|
||||
};
|
||||
};
|
||||
|
||||
function NlTk( ) {
|
||||
//this.type = 'NEWLINE';
|
||||
}
|
||||
NlTk.prototype.toJSON = function () {
|
||||
return { type: 'NlTk' };
|
||||
};
|
||||
|
||||
function CommentTk( value ) {
|
||||
this.type = 'COMMENT';
|
||||
this.value = value;
|
||||
}
|
||||
CommentTk.prototype.toJSON = function () {
|
||||
return {
|
||||
type: 'COMMENT',
|
||||
value: this.value
|
||||
};
|
||||
};
|
||||
function EOFTk( ) {
|
||||
this.type = 'END';
|
||||
}
|
||||
EOFTk.prototype.toJSON = function () {
|
||||
return { type: 'EOFTk' };
|
||||
};
|
||||
|
||||
// A key-value pair
|
||||
function KV ( k, v ) {
|
||||
|
|
Loading…
Reference in a new issue