jquery-powertip icon indicating copy to clipboard operation
jquery-powertip copied to clipboard

Refactor tipElement to use a custom object

Open stevenbenner opened this issue 11 years ago • 0 comments

The abundance of $.data() calls is starting to smell like a missing abstraction. It might be better to create a custom object with the required properties and references. Such an object would need to have all of the current $.data() variables including a reference to the jQuery/DOM element for the element.

This may have several benefits:

  • Make it easier to lint/detect coding errors when accessing properties.
  • Give JIT compilers a chance to optimize a well-known and reused object.
  • Provide a very minor decrease in the time it takes to lookup property values.
  • Define a hard coded contract for tooltip elements.
  • Eliminate most of the name-based DATA_* variables.
  • Opportunity to move hook-once code blocks to methods instead of "HasFoo" checks.

I'm not sure if this would have a positive or negative net effect on the file size of the minified code. As long as it doesn't add a significant amount of weight to the file then the readability improvement alone should justify the change.

Investigate if this is a good idea, and, if so, implement it.

stevenbenner avatar Jun 08 '13 13:06 stevenbenner