Skip to content

Commit

Permalink
fix(context): ⚓ Removes argument to getters
Browse files Browse the repository at this point in the history
The `__get*` methods on the CanvasRenderingContext2D
class currently take an unnecessary `ctx` argument.
This is inconsistent with both the README and the
TypeScript interface's documentation of these
methods. This change removes the argument and updates
the tests to match.
  • Loading branch information
Griffin Rademacher committed Oct 1, 2019
1 parent 66a7986 commit ef97629
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const path = new Path2D();
path.arc(100, 101, 10, 0, Math.PI * 2);

afterEach(() => {
const drawCalls = ctx.__getDrawCalls(ctx);
const drawCalls = ctx.__getDrawCalls();
expect(drawCalls).toMatchSnapshot();
});

Expand Down
2 changes: 1 addition & 1 deletion __tests__/classes/CanvasRenderingContext2D.__getEvents.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ path.arc(100, 101, 10, 0, Math.PI * 2);
const imgData = new ImageData(100, 100);

afterEach(() => {
const drawCalls = ctx.__getEvents(ctx);
const drawCalls = ctx.__getEvents();
expect(drawCalls).toMatchSnapshot();
});

Expand Down
2 changes: 1 addition & 1 deletion __tests__/classes/CanvasRenderingContext2D.__getPath.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const path = new Path2D();
path.arc(100, 101, 10, 0, Math.PI * 2);

afterEach(() => {
const drawCalls = ctx.__getPath(ctx);
const drawCalls = ctx.__getPath();
expect(drawCalls).toMatchSnapshot();
});

Expand Down
6 changes: 3 additions & 3 deletions src/classes/CanvasRenderingContext2D.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default class CanvasRenderingContext2D {
* an event is added to this array. This goes for every property set, and draw call.
*/
_events = [];
__getEvents(ctx) {
__getEvents() {
return this._events.slice();
}

Expand All @@ -56,8 +56,8 @@ export default class CanvasRenderingContext2D {
* path.
*/
_path = [createCanvasEvent('beginPath', [1, 0, 0, 1, 0, 0], {})];
__getPath(ctx) {
return ctx._path.slice();
__getPath() {
return this._path.slice();
}

_directionStack = ['inherit'];
Expand Down

0 comments on commit ef97629

Please sign in to comment.