diegoles / closure-library

Automatically exported from code.google.com/p/closure-library
0 stars 0 forks source link

Requiring goog.ui.Gauge results in 'ERROR - Property value never defined on goog.ui.Gauge' #523

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago

What steps will reproduce the problem?
1. goog.require('goog.ui.Gauge')

What is the expected output? What do you see instead?
I expect to be able to use this component. Instead I see 'ERROR - Property 
value never defined on goog.ui.Gauge' 

What version of the product are you using? On what operating system?
I have tried with the latest version of Plovr, which apparently includes 
closure-library HEAD from around Oct. 2012. I also checked out the latest 
version of closure-library and plopped it in plovr as a replacement. That 
didn't work either. 

Please provide any additional information below.
Note, I am just an end user and I don't really know how plovr and closure are 
set up to develop together. Just trying to see if it's something I'm doing 
wrong. Has the gauge been broken for a long time?

Original issue reported on code.google.com by j...@highvolumeseller.com on 23 Dec 2012 at 9:05

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Hi. I found the bug in the code. You guys have to change 

    this.valuePosition_ = this.valueToRangePosition_(this.value);

to 

    this.needleValuePosition_ = this.valueToRangePosition_(this.value_);

in the app.ui.Gauge.prototype.draw_ routine. Notice the underscore after value 
in the second line.

Original comment by j...@highvolumeseller.com on 23 Dec 2012 at 11:21

GoogleCodeExporter commented 8 years ago
The monkey patch below appears to work when put before the require.

// monkey patch
goog.ui.Gauge.prototype.value = (goog.bind(function () {
    return this.value_;
}, goog.ui.Gauge.prototype))();
goog.ui.Gauge.prototype.valuePosition_ = (function (val) {
    goog.ui.Gauge.prototype.needleValuePosition_ = val;
})(goog.ui.Gauge.prototype.value);
// end monkey patch

goog.require('goog.ui.Gauge');

Original comment by j...@highvolumeseller.com on 24 Dec 2012 at 12:28

GoogleCodeExporter commented 8 years ago
goog.require('goog.ui.Gauge') and the code that uses gauges must be put into 
separate <script> blocks.

Original comment by pall...@google.com on 26 Dec 2012 at 8:13

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
In gauge.js, there is no 'value' variable, nor is there a 'valuePosition_' 
variable defined. However, both variables are being used and causing an error. 
I don't know if its the result of a bad merge or what, but it is broken code. 
Again, it should be: this.needleValuePosition_ = 
this.valueToRangePosition_(this.value_);

Original comment by j...@highvolumeseller.com on 26 Dec 2012 at 8:23

GoogleCodeExporter commented 8 years ago
Additionally, I do not believe there is a requirement to put the imports in 
separate script blocks. I am not doing that, nor is it mentioned anywhere in 
the documentation for gauge.

Original comment by j...@highvolumeseller.com on 26 Dec 2012 at 8:25

GoogleCodeExporter commented 8 years ago
Reading this.value in line 790 of 
https://code.google.com/searchframe#epIciakqvFc/trunk/closure/goog/ui/gauge.js&l
=790 is indeed a bug.

The fact that modules have to be loaded and used in separate script blocks 
isn't specific to goog.ui.Gauge. It's the consequence of JavaScript's 
asynchronous nature. But apparently your issue was caused by the typo in 
goog.ui.Gauge.prototype.draw_.: 

Original comment by pall...@google.com on 26 Dec 2012 at 8:37

GoogleCodeExporter commented 8 years ago
Thanks.

Original comment by j...@highvolumeseller.com on 26 Dec 2012 at 8:41