-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Convert Rect to Es6, remove global scope function. #8118
Conversation
Code Coverage Summary
|
Code Coverage Summary
|
Code Coverage Summary
|
Code Coverage Summary
|
Code Coverage Summary
|
Code Coverage Summary
|
Code Coverage Summary
|
Code Coverage Summary
|
@ShaMan123 i re-enabled Lint because this will force people working on a file to clean their file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello Rect!
src/shapes/rect.class.ts
Outdated
const x = -w / 2; | ||
const y = -h / 2; | ||
rx = rx ? Math.min(rx, w / 2) : 0; | ||
ry = this.ry ? Math.min(ry, h / 2) : 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can inline this and make a const
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you mean?
* @memberOf Rect | ||
* @see: http://www.w3.org/TR/SVG/shapes.html#RectElement | ||
*/ | ||
Rect.ATTRIBUTE_NAMES = fabric.SHARED_ATTRIBUTES.concat('x y rx ry width height'.split(' ')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really don't like the 'a b c'.split(' ')
concept
Can we dump it?
TS won't like it either if we enforce types on ATTRIBUTE_NAMES
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can dump it yes, we will probably have enums for those, but right now i really don't care.
return callback(null); | ||
} | ||
const { | ||
left = 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WOW I didn't know this was possible!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this highligtherd an issue of this code.
visible needs to be default true. Because ti requires the knowledge of the fact that the attribute default value on SVG is true. It broke my tests for long, i tought it was an es6 issue, while it was just a real code change i introduced without knowing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
visible false is hidden, visible undefined means visible.
src/shapes/rect.class.ts
Outdated
visible = true, | ||
...RestOfparsedAttributes | ||
} = fabric.parseAttributes(element, Rect.ATTRIBUTE_NAMES); | ||
const rect = new Rect(Object.assign({}, options, RestOfparsedAttributes, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assign go away!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RestOfparsedAttributes
-> restOfParsedAttributes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh right let's remove this.
Code Coverage Summary
|
src/shapes/rect.class.ts
Outdated
@@ -77,7 +77,7 @@ const Rect = fabric.util.createClass(fabric.Object, /** @lends Rect.prototype */ | |||
const x = -w / 2; | |||
const y = -h / 2; | |||
rx = rx ? Math.min(rx, w / 2) : 0; | |||
ry = this.ry ? Math.min(ry, h / 2) : 0; | |||
ry = ry ? Math.min(ry, h / 2) : 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant
ry = ry ? Math.min(ry, h / 2) : 0; | |
const ry = this.ry ? Math.min(this.ry, h / 2) : 0; |
and remove let ry
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok now i done it differently. is not really an issue.
Code Coverage Summary
|
No description provided.