-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Removing (most) Closure from BlockFactory #1925
Conversation
Removing unused method generateToolboxFromLibrary().
Removing goog.require('BlockLibraryController') elsewhere.
8ae732f
to
4cd4f3b
Compare
BlockDefinitionExtractor.newDomElement_('value', {name: 'COLOUR'}); | ||
colourInputValue.append(colourBlock); | ||
factoryBaseEl.append(colourInputValue); | ||
var colour_hue = block.getHue(); // May be null if not set via hue. |
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.
Are these TODOs actually done now?
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.
* @param {!BlockLibraryStorage} blockLibStorage Block Library Storage object. | ||
* @return {!Element} XML representation of the toolbox. | ||
*/ | ||
BlockExporterTools.prototype.generateToolboxFromLibrary |
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.
was this unused?
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.
Yes.
// goog.global is synonymous to window, and allows for flexibility | ||
// between browsers. | ||
var object = goog.global.localStorage[this.name]; | ||
var object = localStorage[this.name]; |
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.
none of the browsers require this to be window.?
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.
window is the global scope in a browser context: https://stackoverflow.com/a/12660102/152543
var option = document.createElement('a'); | ||
option.id ='dropdown_' + blockType; | ||
option.classList.add('blockLibOpt'); | ||
option.innerHTML = blockType; |
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 try and avoid innerHtml. What is this? can it be option.textNode = blockType (or whatever it actually is)
demos/blockfactory/block_option.js
Outdated
}, this.blockType); | ||
var labelText = document.createElement('p'); | ||
labelText.id = this.blockType + '_text'; | ||
labelText.innerHTML = this.blockType; |
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.
same innerHtml comment here.
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.
Replaced all .innerHTML
assignments with .textContent
.
BlockDefinitionExtractor.newDomElement_('value', {name: 'COLOUR'}); | ||
colourInputValue.append(colourBlock); | ||
factoryBaseEl.append(colourInputValue); | ||
var colour_hue = block.getHue(); // May be null if not set via hue. |
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.
* @param {!BlockLibraryStorage} blockLibStorage Block Library Storage object. | ||
* @return {!Element} XML representation of the toolbox. | ||
*/ | ||
BlockExporterTools.prototype.generateToolboxFromLibrary |
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.
Yes.
// goog.global is synonymous to window, and allows for flexibility | ||
// between browsers. | ||
var object = goog.global.localStorage[this.name]; | ||
var object = localStorage[this.name]; |
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.
window is the global scope in a browser context: https://stackoverflow.com/a/12660102/152543
demos/blockfactory/color_picker.js
Outdated
*/ | ||
|
||
/** | ||
* @fileoverview Color picker used to select the color of a toolbox category. |
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.
did you mean to add this file in this commit?
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.
Ummm... what file? 👀
(removed)
2db5fec
to
99fb78d
Compare
LGTM |
The basics
The details
Resolves
#668 (partially)
Proposed Changes
Replacing all Closure
goog.
library calls from BlockFactory, with the exception of the ColorPicker and the test for the warning about running without Closure. This includes (almost) allgoog.provide
andgoog.require
statements.Final status:
I'll remove the ColorPicker and warning in a follow-up PR.
Reason for Changes
Recent changes in Closure have been breaking BlockFactory, which uses Closure libraries but was not compiled by the Closure Compiler. This also simplifies use for people host their own BlockFactory, or running the local file from the repo.
Test Coverage
Every changed function and class was run at least once (manual testing), verifying I did not break its primary behavior. Most changes are trivial.
Tested on: