Skip to content

Commit 9dd5a64

Browse files
author
Steve Hobbs
authored
Remove javascript:void(0) from links that do not navigate (#1938)
* Remove javascript:void(0) from links that do not navigate * Fix snapshots
1 parent 247f9ef commit 9dd5a64

File tree

7 files changed

+44
-30
lines changed

7 files changed

+44
-30
lines changed

src/__tests__/connection/passwordless/__snapshots__/email_sent_confirmation.test.jsx.snap

+15-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@ exports[`EmailSentConfirmation renders correctly 1`] = `
44
<div
55
className="auth0-lock-confirmation"
66
>
7+
<span
8+
aria-label="close"
9+
className="auth0-lock-close-button"
10+
dangerouslySetInnerHTML={
11+
Object {
12+
"__html": "<svg aria-hidden=\\"true\\" focusable=\\"false\\" enable-background=\\"new 0 0 128 128\\" version=\\"1.1\\" viewBox=\\"0 0 128 128\\" xml:space=\\"preserve\\" xmlns=\\"http://www.w3.org/2000/svg\\" xmlns:xlink=\\"http://www.w3.org/1999/xlink\\"><g><polygon fill=\\"#373737\\" points=\\"123.5429688,11.59375 116.4765625,4.5185547 64.0019531,56.9306641 11.5595703,4.4882813 4.4882813,11.5595703 56.9272461,63.9970703 4.4570313,116.4052734 11.5244141,123.4814453 63.9985352,71.0683594 116.4423828,123.5117188 123.5126953,116.4414063 71.0732422,64.0019531 \\"></polygon></g></svg>",
13+
}
14+
}
15+
id="__lock-id__-close-button"
16+
onClick={[Function]}
17+
onKeyPress={[Function]}
18+
role="button"
19+
tabIndex={0}
20+
/>
721
<span
822
aria-label="back"
923
className="auth0-lock-back-button"
@@ -40,7 +54,7 @@ exports[`EmailSentConfirmation renders correctly 1`] = `
4054
<span>
4155
<a
4256
className="auth0-lock-resend-link"
43-
href="javascript:void(0)"
57+
href="#"
4458
onClick={[Function]}
4559
>
4660

src/__tests__/field/__snapshots__/vcode_pane.test.jsx.snap

+5-5
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ exports[`VcodePane disable input when submitting 1`] = `
3333
>
3434
<a
3535
className="auth0-lock-alternative-link"
36-
href="javascript:void(0)"
36+
href="#"
3737
onClick={[Function]}
3838
>
3939
resendLabel
@@ -59,7 +59,7 @@ exports[`VcodePane renders correctly 1`] = `
5959
>
6060
<a
6161
className="auth0-lock-alternative-link"
62-
href="javascript:void(0)"
62+
href="#"
6363
onClick={[Function]}
6464
>
6565
resendLabel
@@ -85,7 +85,7 @@ exports[`VcodePane sets autoFocus as true when \`isSmallScreen\` is false 1`] =
8585
>
8686
<a
8787
className="auth0-lock-alternative-link"
88-
href="javascript:void(0)"
88+
href="#"
8989
onClick={[Function]}
9090
>
9191
resendLabel
@@ -111,7 +111,7 @@ exports[`VcodePane sets isValid as true when \`isFieldVisiblyInvalid\` is false
111111
>
112112
<a
113113
className="auth0-lock-alternative-link"
114-
href="javascript:void(0)"
114+
href="#"
115115
onClick={[Function]}
116116
>
117117
resendLabel
@@ -142,7 +142,7 @@ exports[`VcodePane shows header when instructions are available 1`] = `
142142
>
143143
<a
144144
className="auth0-lock-alternative-link"
145-
href="javascript:void(0)"
145+
href="#"
146146
onClick={[Function]}
147147
>
148148
resendLabel

src/connection/database/login_pane.jsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import * as l from '../../core/index';
99
import CaptchaPane from '../../field/captcha/captcha_pane';
1010

1111
export default class LoginPane extends React.Component {
12-
handleDontRememberPasswordClick(e) {
12+
handleDontRememberPasswordClick = e => {
1313
e.preventDefault();
1414
showResetPasswordActivity(l.id(this.props.lock));
15-
}
15+
};
1616

1717
render() {
1818
const {
@@ -65,8 +65,8 @@ export default class LoginPane extends React.Component {
6565
<p className="auth0-lock-alternative">
6666
<a
6767
className="auth0-lock-alternative-link"
68-
href={forgotPasswordLink(lock, 'javascript:void(0)')}
69-
onClick={forgotPasswordLink(lock) ? undefined : ::this.handleDontRememberPasswordClick}
68+
href={forgotPasswordLink(lock, '#')}
69+
onClick={forgotPasswordLink(lock) ? undefined : this.handleDontRememberPasswordClick}
7070
>
7171
{forgotPasswordAction}
7272
</a>

src/connection/database/login_sign_up_tabs.jsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@ LoginSignUpTabs.propTypes = {
5454
};
5555

5656
class LoginSignUpTab extends React.Component {
57-
handleClick(e) {
57+
handleClick = e => {
5858
if (this.props.href) {
5959
this.props.clickWithHrefHandler();
6060
} else {
6161
e.preventDefault();
6262
this.props.clickHandler();
6363
}
64-
}
64+
};
6565

6666
render() {
6767
const { current, href, label } = this.props;
@@ -72,7 +72,7 @@ class LoginSignUpTab extends React.Component {
7272
{current ? (
7373
<span>{label}</span>
7474
) : (
75-
<a href={href || 'javascript:void(0)'} onClick={::this.handleClick}>
75+
<a href={href || '#'} onClick={this.handleClick}>
7676
{label}
7777
</a>
7878
)}

src/connection/passwordless/email_sent_confirmation.jsx

+10-6
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class ResendLink extends React.Component {
1616
render() {
1717
const { label, onClick } = this.props;
1818
return (
19-
<a className="auth0-lock-resend-link" href="javascript:void(0)" onClick={onClick}>
19+
<a className="auth0-lock-resend-link" href="#" onClick={onClick}>
2020
{label} <span dangerouslySetInnerHTML={{ __html: retrySvg }} />
2121
</a>
2222
);
@@ -29,7 +29,7 @@ class Resend extends React.Component {
2929

3030
const resendLink = m.resendAvailable(lock) && (
3131
<ResendLink
32-
onClick={::this.handleClick}
32+
onClick={this.handleClick}
3333
label={m.resendFailed(lock) ? labels.retry : labels.resend}
3434
/>
3535
);
@@ -56,16 +56,16 @@ class Resend extends React.Component {
5656
);
5757
}
5858

59-
handleClick(e) {
59+
handleClick = e => {
6060
e.preventDefault();
6161
resendEmail(l.id(this.props.lock));
62-
}
62+
};
6363
}
6464

6565
export default class EmailSentConfirmation extends React.Component {
6666
render() {
6767
const { lock } = this.props;
68-
const closeHandler = l.ui.closable(lock) ? ::this.handleClose : undefined;
68+
const closeHandler = l.ui.closable(lock) ? this.handleClose : undefined;
6969
const labels = {
7070
failed: i18n.str(lock, 'failedLabel'),
7171
resend: i18n.str(lock, 'resendLabel'),
@@ -75,7 +75,11 @@ export default class EmailSentConfirmation extends React.Component {
7575
};
7676

7777
return (
78-
<SuccessPane lock={lock} backHandler={::this.handleBack} closeHandler={closeHandler}>
78+
<SuccessPane
79+
lock={lock}
80+
backHandler={() => this.handleBack()}
81+
closeHandler={() => closeHandler()}
82+
>
7983
<p>{i18n.html(lock, ['success', 'magicLink'], c.email(lock))}</p>
8084
<Resend labels={labels} lock={lock} />
8185
</SuccessPane>

src/field/vcode/vcode_pane.jsx

+6-10
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ import { swap, updateEntity } from '../../store/index';
88
import { setVcode } from '../vcode';
99

1010
export default class VcodePane extends React.Component {
11-
handleVcodeChange(e) {
11+
handleVcodeChange = e => {
1212
e.preventDefault();
1313
swap(updateEntity, 'lock', l.id(this.props.lock), setVcode, e.target.value);
14-
}
14+
};
1515

16-
handleResendClick(e) {
16+
handleResendClick = e => {
1717
e.preventDefault();
1818
const { lock, onRestart } = this.props;
1919
onRestart(l.id(lock));
20-
}
20+
};
2121

2222
render() {
2323
const { instructions, lock, placeholder, resendLabel } = this.props;
@@ -31,17 +31,13 @@ export default class VcodePane extends React.Component {
3131
lockId={l.id(lock)}
3232
value={c.vcode(lock)}
3333
isValid={!c.isFieldVisiblyInvalid(lock, 'vcode') && !l.globalError(lock)}
34-
onChange={::this.handleVcodeChange}
34+
onChange={this.handleVcodeChange}
3535
autoFocus={!isSmallScreen()}
3636
placeholder={placeholder}
3737
disabled={l.submitting(lock)}
3838
/>
3939
<p className="auth0-lock-alternative">
40-
<a
41-
className="auth0-lock-alternative-link"
42-
href="javascript:void(0)"
43-
onClick={::this.handleResendClick}
44-
>
40+
<a className="auth0-lock-alternative-link" href="#" onClick={this.handleResendClick}>
4541
{resendLabel}
4642
</a>
4743
</p>

src/ui/pane/quick_auth_pane.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const QuickAuthPane = props => {
1919
<p className="auth0-lock-alternative">
2020
<a
2121
className="auth0-lock-alternative-link"
22-
href="javascript:void(0)"
22+
href="#"
2323
onClick={e => {
2424
e.preventDefault();
2525
alternativeClickHandler(e);

0 commit comments

Comments
 (0)