Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for the potential semantic confusion between settings, defaults, …
…and options. Prior to this change, these two files used settings, something called "defaultOptions", and options. Using "defaultOptions" is problematic because it does not cleanly separate defaults and options. It needlessly confounds the two. The `namespaced-starter.html` file actually fell into this trap. See the comment on line 36 here: chuanxshi@7f3d3d3#jquery-plugin-patterns/namespaced-starter.html Besides "defaults" is a better term than "defaultOptions". This may matter for non-English native readers. THEREFORE options: values provided by the plugin's calling code. defaults: the settings provided A-Priori by the plugin settings: the final, amalgamated run-time spec for the plugin An additional benefit: cleanly separating options, defaults, and settings makes these available for subsequent runs of the plugin without mutating the plugin's defaults, which can be restored at anytime without redefining the plugin. This is not so much a problem for these two examples, but there are other jQuery plugin patterns in this collection where this definitely applies. For example, https://github.com/shichuan/javascript-patterns/blob/master/jquery-plugin-patterns/best-options.html where "options" is (for the moment) used in lieu of settings, thus destroying the user-provided options object. I'll fix that separately. Signed-off-by: Steven Black <[email protected]>
- Loading branch information