Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore() remove unnecessary typeof === 'undefined' #8953

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Observable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export class Observable<EventSpec> {
}

// remove all key/value pairs (event name -> event handler)
if (typeof arg0 === 'undefined') {
if (arg0 === undefined) {
for (const eventName in this.__eventListeners) {
this._removeEventListener(eventName);
}
Expand Down
2 changes: 1 addition & 1 deletion src/parser/parseAttributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function parseAttributes(
fontSize,
parentFontSize;

if (typeof svgUid === 'undefined') {
if (svgUid === undefined) {
svgUid = element.getAttribute('svgUid');
}
// if there's a parent container (`g` or `a` or `symbol` node), parse its attributes recursively upwards
Expand Down
2 changes: 1 addition & 1 deletion src/parser/parseStyleObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
export function parseStyleObject(style, oStyle) {
let attr, value;
for (const prop in style) {
if (typeof style[prop] === 'undefined') {
if (style[prop] === undefined) {
continue;
}

Expand Down
4 changes: 2 additions & 2 deletions src/parser/setStrokeFillOpacity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import { FabricObject } from '../shapes/Object/FabricObject';
export function setStrokeFillOpacity(attributes) {
for (const attr in colorAttributes) {
if (
typeof attributes[colorAttributes[attr]] === 'undefined' ||
attributes[colorAttributes[attr]] === undefined ||
attributes[attr] === ''
) {
continue;
}
const defaults = FabricObject.getDefaults();
if (typeof attributes[attr] === 'undefined') {
if (attributes[attr] === undefined) {
if (!defaults[attr]) {
continue;
}
Expand Down
12 changes: 3 additions & 9 deletions src/shapes/Text/StyledText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ export abstract class StyledText<
return true;
}
const obj =
typeof lineIndex === 'undefined'
? this.styles
: { line: this.styles[lineIndex] };
lineIndex === undefined ? this.styles : { line: this.styles[lineIndex] };
for (const p1 in obj) {
for (const p2 in obj[p1]) {
// eslint-disable-next-line no-unused-vars
Expand All @@ -70,9 +68,7 @@ export abstract class StyledText<
return false;
}
const obj =
typeof lineIndex === 'undefined'
? this.styles
: { 0: this.styles[lineIndex] };
lineIndex === undefined ? this.styles : { 0: this.styles[lineIndex] };
// eslint-disable-next-line
for (const p1 in obj) {
// eslint-disable-next-line
Expand Down Expand Up @@ -274,9 +270,7 @@ export abstract class StyledText<
for (let i = 0; i < styleProps.length; i++) {
const prop = styleProps[i];
styleObject[prop] =
typeof style[prop] === 'undefined'
? this[prop as keyof this]
: style[prop];
style[prop] === undefined ? this[prop as keyof this] : style[prop];
}
return styleObject;
}
Expand Down
4 changes: 1 addition & 3 deletions src/shapes/Textbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,7 @@ export class Textbox extends IText {
nextOffset = mapNextLine.offset;
}
const obj =
typeof lineIndex === 'undefined'
? this.styles
: { line: this.styles[lineIndex] };
lineIndex === undefined ? this.styles : { line: this.styles[lineIndex] };
for (const p1 in obj) {
for (const p2 in obj[p1]) {
if (p2 >= offset && (!shouldLimit || p2 < nextOffset)) {
Expand Down
2 changes: 1 addition & 1 deletion src/util/misc/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { ImageFormat } from '../../typedefs';
*/
export const createCanvasElement = (): HTMLCanvasElement => {
const element = getFabricDocument().createElement('canvas');
if (!element || typeof element.getContext === 'undefined') {
if (!element || element.getContext === undefined) {
throw new Error('Failed to create `canvas` element');
}
return element;
Expand Down