r110656 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110655‎ | r110656 | r110657 >
Date:13:09, 3 February 2012
Author:gwicke
Status:deferred
Tags:
Comment:
Add custom JSON serializers for tokens that include a type attribute
Modified paths:
  • /trunk/extensions/VisualEditor/modules/parser/mediawiki.parser.defines.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/parser/mediawiki.parser.defines.js
@@ -8,26 +8,63 @@
99 this.attribs = attribs || [];
1010 }
1111
 12+TagTk.prototype.toJSON = function () {
 13+ return {
 14+ type: 'TagTk',
 15+ name: this.name,
 16+ attribs: this.attribs
 17+ };
 18+};
 19+
1220 function EndTagTk( name, attribs ) {
1321 //this.type = 'ENDTAG';
1422 this.name = name;
1523 this.attribs = attribs || [];
1624 }
 25+EndTagTk.prototype.toJSON = function () {
 26+ return {
 27+ type: 'EndTagTk',
 28+ name: this.name,
 29+ attribs: this.attribs
 30+ };
 31+};
 32+
1733 function SelfclosingTagTk( name, attribs ) {
1834 //this.type = 'SELFCLOSINGTAG';
1935 this.name = name;
2036 this.attribs = attribs || [];
2137 }
 38+SelfclosingTagTk.prototype.toJSON = function () {
 39+ return {
 40+ type: 'SelfclosingTagTk',
 41+ name: this.name,
 42+ attribs: this.attribs
 43+ };
 44+};
 45+
2246 function NlTk( ) {
2347 //this.type = 'NEWLINE';
2448 }
 49+NlTk.prototype.toJSON = function () {
 50+ return { type: 'NlTk' };
 51+};
 52+
2553 function CommentTk( value ) {
2654 this.type = 'COMMENT';
2755 this.value = value;
2856 }
 57+CommentTk.prototype.toJSON = function () {
 58+ return {
 59+ type: 'COMMENT',
 60+ value: this.value
 61+ };
 62+};
2963 function EOFTk( ) {
3064 this.type = 'END';
3165 }
 66+EOFTk.prototype.toJSON = function () {
 67+ return { type: 'EOFTk' };
 68+};
3269
3370 // A key-value pair
3471 function KV ( k, v ) {

Status & tagging log