[wp-trac] [WordPress Trac] #20392: user-profile.js causing Javascript error in user-new.php
WordPress Trac
wp-trac at lists.automattic.com
Sat Apr 7 21:21:29 UTC 2012
#20392: user-profile.js causing Javascript error in user-new.php
--------------------------+-----------------------------
Reporter: pbiron | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Users | Version: 3.3.1
Severity: normal | Keywords: 2nd-opinion
--------------------------+-----------------------------
[http://core.trac.wordpress.org/browser/trunk/wp-admin/js/user-
profile.dev.js#L53 Line 53] of user-profile.dev.js is causing a Javascript
error in user-new.php.
The problem is a result of the fact that user-new.php does NOT include
include a "nickname" field. Hence,
[http://core.trac.wordpress.org/browser/trunk/wp-admin/js/user-
profile.dev.js#L40 Line 40] results in `inputs['display_nickname']` being
undefined...and as a result [http://core.trac.wordpress.org/browser/trunk
/wp-admin/js/user-profile.dev.js#L53 Line 53]
{{{
var val = value.replace(/<\/?[a-z][^>]*>/gi, '');
}}}
causes a JS error since `value` is undefined when `id ==
'display_nickname'`.
I can think of at least 3 possible fixes:
1. add a "nickname" field to user-new.php
2. replace [http://core.trac.wordpress.org/browser/trunk/wp-admin/js/user-
profile.dev.js#L40 Line 40] with something like `display_nickname :
$('#nickname').val() ? $('#nickname').val () : '',`
3. wrap lines 53-62 of user-profile.dev.js in `if (undefined != value) {}`
The 3rd solution seems the most general (and best) to me, since it future-
proofs user-profile.js for contexts where any of the fields might not be
present. However, I'd really like a 2nd opinion on this before submitting
a patch.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/20392>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list