r110768 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110767‎ | r110768 | r110769 >
Date:19:12, 6 February 2012
Author:gwicke
Status:deferred
Tags:
Comment:
Improve toJSON handlers to include all properties
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
@@ -9,11 +9,7 @@
1010 }
1111
1212 TagTk.prototype.toJSON = function () {
13 - return {
14 - type: 'TagTk',
15 - name: this.name,
16 - attribs: this.attribs
17 - };
 13+ return $.extend( { type: 'TagTk' }, this );
1814 };
1915
2016 function EndTagTk( name, attribs ) {
@@ -22,11 +18,7 @@
2319 this.attribs = attribs || [];
2420 }
2521 EndTagTk.prototype.toJSON = function () {
26 - return {
27 - type: 'EndTagTk',
28 - name: this.name,
29 - attribs: this.attribs
30 - };
 22+ return $.extend( { type: 'EndTagTk' }, this );
3123 };
3224
3325 function SelfclosingTagTk( name, attribs ) {
@@ -35,18 +27,14 @@
3628 this.attribs = attribs || [];
3729 }
3830 SelfclosingTagTk.prototype.toJSON = function () {
39 - return {
40 - type: 'SelfclosingTagTk',
41 - name: this.name,
42 - attribs: this.attribs
43 - };
 31+ return $.extend( { type: 'SelfclosingTagTk' }, this );
4432 };
4533
4634 function NlTk( ) {
4735 //this.type = 'NEWLINE';
4836 }
4937 NlTk.prototype.toJSON = function () {
50 - return { type: 'NlTk' };
 38+ return $.extend( { type: 'NlTk' }, this );
5139 };
5240
5341 function CommentTk( value ) {
@@ -54,16 +42,13 @@
5543 this.value = value;
5644 }
5745 CommentTk.prototype.toJSON = function () {
58 - return {
59 - type: 'COMMENT',
60 - value: this.value
61 - };
 46+ return $.extend( { type: 'COMMENT' }, this );
6247 };
6348 function EOFTk( ) {
6449 this.type = 'END';
6550 }
6651 EOFTk.prototype.toJSON = function () {
67 - return { type: 'EOFTk' };
 52+ return $.extend( { type: 'EOFTk' }, this );
6853 };
6954
7055 // A key-value pair

Status & tagging log