Opened 12 years ago
Closed 11 years ago
#23875 closed defect (bug) (fixed)
Twenty Thirteen: improve jQuery code: remove deprecated functions, namespace events, and more
Reported by: | obenland | Owned by: | |
---|---|---|---|
Milestone: | 3.6 | Priority: | normal |
Severity: | normal | Version: | 3.6 |
Component: | Bundled Theme | Keywords: | has-patch |
Focuses: | Cc: |
Description (last modified by )
- The syntax
$(document).on("ready", handler)
is deprecated as of jQuery 1.8.
It behaves similarly to the ready method but if the ready event has already fired and you try to .on("ready")
the bound handler will not be executed. See: http://api.jquery.com/ready/
- We should namespace events: http://docs.jquery.com/Namespaced_Events
- The scroll event should be throttled for performance.
Attachments (5)
Change History (16)
#3
@
12 years ago
- Description modified (diff)
- Keywords needs-refresh added
- Priority changed from low to normal
- Summary changed from Twenty Thirteen: Replace deprecated jQuery code to Twenty Thirteen: improve jQuery code: remove deprecated functions, namespace events, and more
#4
@
12 years ago
- Keywords needs-testing added; needs-refresh removed
.1 patch does the following:
- Moves away from namespaced function names, just make them same scope as other variables
- Add event namespacing
- Add
debounce
function and use it to throttle scroll events - Code comment improvements
#6
@
12 years ago
.3 builds on .2 from obenland to introduce a short delay so we don't trigger an avalanche of function calls with the scroll handler.
Thoughts on the UX? The navbar will hide and show with a tiny delay instead of being instant.
#8
@
12 years ago
Further improvements to the scroll event now pending a decision: we discussed removing the fixed navbar completely today, in IRC #wordpress-dev, see log.
#9
@
11 years ago
@mfields brought to my attention a possible XSS vulnerability at https://wpcom-themes.trac.automattic.com/browser/twentythirteen/js/functions.js#L102
Where we don't check that the hash input is a valid element in the DOM.
See .4 diff for his suggested patch.
This approach is closer to the original code at http://www.nczonline.net/blog/2013/01/15/fixing-skip-to-content-links/ and also closes a possible XSS vulnerability in jQuery Migrate, see https://github.com/jquery/jquery-migrate/issues/36.
I'm going to leave this 'til after beta, we can do some other general refactoring here.