Skip to content

Refactor tipElement to use a custom object #82

Open
@stevenbenner

Description

@stevenbenner

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    RefactorSoftware improvements that do not add any features or correct any defects.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions