Skip to content

Commit e6053b5

Browse files
authored
Merge pull request #7009 from limzykenneth/textwrap-fes
textWrap() parameter validation uses FES instead of throwing error
2 parents 4d52230 + 6ad7e85 commit e6053b5

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

src/typography/attributes.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -539,9 +539,8 @@ p5.prototype._updateTextMetrics = function() {
539539
* </div>
540540
*/
541541
p5.prototype.textWrap = function(wrapStyle) {
542-
if (wrapStyle !== 'WORD' && wrapStyle !== 'CHAR') {
543-
throw 'Error: textWrap accepts only WORD or CHAR';
544-
}
542+
p5._validateParameters('textWrap', [wrapStyle]);
543+
545544
return this._renderer.textWrap(wrapStyle);
546545
};
547546

test/unit/typography/attributes.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,6 @@ suite('Typography Attributes', function() {
113113
});
114114

115115
suite('p5.prototype.textWrap', function() {
116-
test('should throw error for non-constant input', function() {
117-
expect(function() {
118-
myp5.textWrap('NO-WRAP');
119-
}).to.throw('Error: textWrap accepts only WORD or CHAR');
120-
});
121116
test('returns textWrap text attribute', function() {
122117
assert.strictEqual(myp5.textWrap(myp5.WORD), myp5.WORD);
123118
});

0 commit comments

Comments
 (0)