-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Throw Errors instead of using goog.asserts #1664
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
Throw Errors instead of using goog.asserts #1664
Conversation
| Blockly.Block.prototype.setFieldValue = function(newValue, name) { | ||
| var field = this.getField(name); | ||
| goog.asserts.assertObject(field, 'Field "%s" not found.', name); | ||
| if (!field) { |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
| if (!this.previousConnection) { | ||
| goog.asserts.assert(!this.outputConnection, | ||
| 'Remove output connection prior to adding previous connection.'); | ||
| if (this.outputConnection) { |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
| Blockly.Block.prototype.mixin = function(mixinObj, opt_disableCheck) { | ||
| if (goog.isDef(opt_disableCheck) && !goog.isBoolean(opt_disableCheck)) { | ||
| throw new Error("opt_disableCheck must be a boolean if provided"); | ||
| if (opt_disableCheck !== undefined && typeof opt_disableCheck != 'boolean') { |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
| Blockly.BlockDragSurfaceSvg.prototype.setBlocksAndShow = function(blocks) { | ||
| goog.asserts.assert( | ||
| this.dragGroup_.childNodes.length == 0, 'Already dragging a block.'); | ||
| if (this.dragGroup_.childNodes.length) { |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
| this.SVG_.style.display = 'none'; | ||
| goog.asserts.assert( | ||
| this.dragGroup_.childNodes.length == 0, 'Drag group was not cleared.'); | ||
| if (this.dragGroup_.childNodes.length) { |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
| */ | ||
| Blockly.Extensions.registerMixin = function(name, mixinObj) { | ||
| if (!goog.isObject(mixinObj)){ | ||
| if (!mixinObj || typeof mixinObj != 'object'){ |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
| throw new Error('Invalid field type "' + type + '"'); | ||
| } | ||
| if (!goog.isObject(fieldClass) || !goog.isFunction(fieldClass.fromJson)) { | ||
| if (!fieldClass || (typeof fieldClass.fromJson != 'function')) { |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
| */ | ||
| Blockly.utils.startsWith = function(str, prefix) { | ||
| return str.lastIndexOf(prefix, 0) == 0; | ||
| }; |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
| this.SVG_.style.display = 'none'; | ||
| goog.asserts.assert( | ||
| this.SVG_.childNodes.length == 0, 'Drag surface was not cleared.'); | ||
| if (this.SVG_.childNodes.length) { |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
| blockCanvas, bubbleCanvas, previousSibling, width, height, scale) { | ||
| goog.asserts.assert( | ||
| this.SVG_.childNodes.length == 0, 'Already dragging a block.'); | ||
| if (this.SVG_.childNodes.length) { |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
|
@NeilFraser can you comment on some of the RHS/LHS questions? This PR is all code that you changed in Blockly. |
|
@NeilFraser Thanks for answering all the questions! @rachel-fenichel This change looks good to go, but I think we are holding off on making big changes while the new 3.0 banner is up on the scratch website. cc/ @thisandagain |
|
Friendly ping--can we merge this yet? |
|
@rachel-fenichel, I just talked to Ray, and he said it should be okay to merge. |
kchadha
left a comment
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.
LG
Not urgent to review or merge this week.
Resolves
None
Proposed Changes
Mostly just pulling in these changes: RaspberryPiFoundation/blockly@3909bd4
Reason for Changes
Blockly is moving away from using closure library code where possible. We're starting with the easy cases/places where modern browsers standardized so there's no need to hide special casing behind function calls. The eventual goal is to remove the UI widgets and all other dependencies as well.
This change keeps scratch blocks in line with some of the recent blockly work. There will be other related changes.
Test Coverage
I built and played with the vertical playground.