Opened 13 years ago

Closed 13 years ago

#6947 closed feature (fixed)

Attempt to access private member of widget returns jQuery object

Reported by: wkmanire Owned by:
Priority: major Milestone: 1.9.0
Component: ui.widget Version: 1.8.9
Keywords: Cc:
Blocked by: Blocking:


I'm submitting this as a bug, but I think this could be classified as an enhancement.

ui.widget's bridge method protects against calling pseudo-private methods that start with an underscore by immediately returning "this". In my opinion, it should instead throw an exception to inform the developer that the widget is not being used properly. I can see the potential for a hard to detect bug going into production code as a result of the current behavior.

// starting on line 73 of jquery.ui.widget.js
var isMethodCall = typeof options === "string",
  args = arguments, 1 ),
  returnValue = this;

// then on line 83 returnValue remains "this"

// prevent calls to internal methods
if ( isMethodCall && options.charAt( 0 ) === "_" ) {
  // perhaps instead at this point $.error('jquery.ui.widget: Attempt to access private member ' + options);
  return returnValue;

Change History (5)

comment:1 Changed 13 years ago by Scott González

Priority: minormajor
Status: newopen
Type: bugfeature

We should treat this the same as non-existant methods. See #5972 for a related change.

comment:2 Changed 13 years ago by wkmanire

I just submitted a pull request for this. I goofed up and accidently copied another unit test on my first commit so there are actually two commits. The first commit has the fix, a unit test, and an erroneous copy paste. The second removes the erroneous copy paste.



comment:3 Changed 13 years ago by wkmanire

I took another stab at this according to scott.gonzalez's direction. Should I submit another pull request? I read the guidelines but I'm still not completely familiar with this process.

Here is the commit:

comment:4 Changed 13 years ago by wkmanire

Next pull request is ready. Attempts to execute private methods are treated the same as missing methods. Unit test code integrated into errors test.

Here is the commit for it:

comment:5 Changed 13 years ago by William Kevin Manire

Resolution: fixed
Status: openclosed

Widget: modified widget to throw exception on attempt to call private methods. Fixed #6947 - Attempt to access private member of widget returns jQuery object

Changeset: c94ec23b263464af3dfa4533eff45fc0d6fef954

Note: See TracTickets for help on using tickets.