From d216c0fe5fa9d6c7e886b923972d789848436ed9 Mon Sep 17 00:00:00 2001 From: Jeff Avallone Date: Sat, 13 Dec 2014 13:42:55 -0500 Subject: [PATCH] Simplifying more code --- src/js/parser/javascript/charset_range.js | 18 +++++++++--------- src/js/parser/javascript/escape.js | 11 ++++++----- src/js/parser/javascript/literal.js | 11 ++++++----- src/js/parser/javascript/match.js | 10 ++++------ 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/js/parser/javascript/charset_range.js b/src/js/parser/javascript/charset_range.js index 31ca1ea..c8980a0 100644 --- a/src/js/parser/javascript/charset_range.js +++ b/src/js/parser/javascript/charset_range.js @@ -6,19 +6,19 @@ export default _.extend({}, Base, { type: 'charset-range', _render() { - var hyphen = this.container.text() - .attr({ - text: '-' - }); + var contents = [ + this.first, + this.container.text() + .attr({ text: '-' }), + this.last + ]; return Q.all([ this.first.render(this.container.group()), this.last.render(this.container.group()) ]) - .then((() => { - this.spaceHorizontally([this.first, hyphen, this.last], { - padding: 5 - }); - }).bind(this)); + .then(this.spaceHorizontally.bind(this, contents, { + padding: 5 + })); } }); diff --git a/src/js/parser/javascript/escape.js b/src/js/parser/javascript/escape.js index 6804618..f55f91f 100644 --- a/src/js/parser/javascript/escape.js +++ b/src/js/parser/javascript/escape.js @@ -13,12 +13,13 @@ export default _.extend({}, Base, { }, _render() { - return this.renderLabel(_.result(this, this.code())).then(label => { - label.select('rect').attr({ - rx: 3, - ry: 3 + return this.renderLabel(_.result(this, this.code())) + .then(label => { + label.select('rect').attr({ + rx: 3, + ry: 3 + }); }); - }); }, // Escape code mappings diff --git a/src/js/parser/javascript/literal.js b/src/js/parser/javascript/literal.js index 3e3ff9c..c7444c1 100644 --- a/src/js/parser/javascript/literal.js +++ b/src/js/parser/javascript/literal.js @@ -5,11 +5,12 @@ export default _.extend({}, Base, { type: 'literal', _render() { - return this.renderLabel('"' + this.literal.textValue + '"').then(label => { - label.select('rect').attr({ - rx: 3, - ry: 3 + return this.renderLabel('"' + this.literal.textValue + '"') + .then(label => { + label.select('rect').attr({ + rx: 3, + ry: 3 + }); }); - }); } }); diff --git a/src/js/parser/javascript/match.js b/src/js/parser/javascript/match.js index 6fba587..526fc49 100644 --- a/src/js/parser/javascript/match.js +++ b/src/js/parser/javascript/match.js @@ -11,15 +11,13 @@ export default _.extend({}, Base, { partPromises; if (this.anchorStart()) { - start = this.renderLabel('Start of line').then(label => { - return label.addClass('anchor'); - }); + start = this.renderLabel('Start of line') + .invoke('addClass', 'anchor'); } if (this.anchorEnd()) { - end = this.renderLabel('End of line').then(label => { - return label.addClass('anchor'); - }); + end = this.renderLabel('End of line') + .invoke('addClass', 'anchor'); } if (start || end || parts.length !== 1) {