Skip to content

Commit 6e84797

Browse files
UncleJartdiegoddox
authored andcommitted
fix W3C validation errors
1 parent 756c901 commit 6e84797

File tree

6 files changed

+40
-18
lines changed

6 files changed

+40
-18
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# v7.5.2
2+
[#245] Fix W3C validation errors
3+
14
# v7.4.10
25
Allow latest react-redux as peer dependency
36
[#230]

development/Avatar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ const styles = {
1111

1212
export default () => (
1313
<div className="toastr-avatar" style={styles}>
14-
<img src="./assets/jesus.jpg" style={{maxWidth: '105%'}}/>
14+
<img src="./assets/jesus.jpg" alt="avatar" style={{maxWidth: '105%'}}/>
1515
</div>
1616
);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-redux-toastr",
3-
"version": "7.5.1",
3+
"version": "7.5.2",
44
"description": "react-redux-toastr is a React toastr message implemented with Redux",
55
"main": "lib/index.js",
66
"jsnext:main": "./src/index.js",

src/ReduxToastr.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export class ReduxToastr extends React.Component {
9797
};
9898

9999
return (
100-
<span key={item.id}>
100+
<div key={item.id}>
101101
<ToastrBox
102102
inMemory={this.toastrFired}
103103
addToMemory={() => this._addToMemory(item.id)}
@@ -115,7 +115,7 @@ export class ReduxToastr extends React.Component {
115115
}}
116116
className="toastr-attention"/>
117117
}
118-
</span>
118+
</div>
119119
);
120120
});
121121
}
@@ -126,30 +126,30 @@ export class ReduxToastr extends React.Component {
126126
const width = toastr.toastrs && toastr.toastrs[0] && toastr.toastrs[0].options && toastr.toastrs[0].options.width;
127127
const style = width ? {width: width} : {};
128128
return (
129-
<span>
129+
<div>
130130
{this.toastrPositions.map(position => {
131131
return (
132132
<div key={position} className={position} style={style}>
133133
{this._renderToastrForPosition(position)}
134134
</div>
135135
);
136136
})}
137-
</span>
137+
</div>
138138
);
139139
}
140140

141141
render() {
142142
const {className, toastr} = this.props;
143143
return (
144-
<span className={cn('redux-toastr', className)} aria-live="assertive">
144+
<div className={cn('redux-toastr', className)} aria-live="assertive">
145145
{toastr.confirm &&
146146
<ToastrConfirm
147147
confirm={toastr.confirm}
148148
{...this.props}
149149
/>
150150
}
151151
{this._renderToastrs()}
152-
</span>
152+
</div>
153153
);
154154
}
155155
}

src/ToastrBox.js

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,13 @@ export default class ToastrBox extends React.Component {
9292
}, 50);
9393
}
9494

95+
get isToastrClickable() {
96+
const {onToastrClick, closeOnToastrClick} = this.props.item.options;
97+
const hasOnToastrClick = !!onToastrClick;
98+
99+
return hasOnToastrClick || closeOnToastrClick;
100+
}
101+
95102
handlePressEnterOrSpaceKeyToastr = (e) => {
96103
if (e.key === ' ' || e.key === 'enter') {
97104
this.handleClickToastr(e);
@@ -196,17 +203,24 @@ export default class ToastrBox extends React.Component {
196203
}
197204

198205
renderCloseButton() {
206+
let closeButtonAttributes = {
207+
tabIndex: 0,
208+
role: 'button',
209+
onKeyPress: this.handlePressEnterOrSpaceKeyCloseButton
210+
};
211+
if (this.isToastrClickable) {
212+
closeButtonAttributes = {};
213+
}
199214
return (
200-
<button
201-
tabIndex="0"
202-
type="button"
215+
<div
203216
className="close-toastr toastr-control"
204217
aria-label="toast"
205218
onClick={this.handleClickCloseButton}
206219
ref={ref => this.closeButton = ref}
220+
{...closeButtonAttributes}
207221
>
208-
&#x2715;
209-
</button>
222+
<span>&#x2715;</span>
223+
</div>
210224
);
211225
}
212226

@@ -352,12 +366,8 @@ export default class ToastrBox extends React.Component {
352366
type
353367
} = this.props.item;
354368

355-
const {onToastrClick, closeOnToastrClick} = options;
356-
const hasOnToastrClick = !!onToastrClick;
357-
const doesCloseOnToastrClick = closeOnToastrClick;
358-
359369
let toastrClickAttributes = {};
360-
if (hasOnToastrClick || doesCloseOnToastrClick) {
370+
if (this.isToastrClickable) {
361371
toastrClickAttributes.role = 'button';
362372
toastrClickAttributes.tabIndex = 0;
363373
toastrClickAttributes.onClick = this.handleClickToastr;

src/styles/index.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ body.toastr-confirm-active {
153153
opacity: 0.5;
154154
cursor: pointer;
155155
font-family: "Helvetica Neue", Helvetica, Arial sans-serif;
156+
color: #000;
156157

157158
&:hover {
158159
opacity: 1;
@@ -161,6 +162,14 @@ body.toastr-confirm-active {
161162
&:focus {
162163
outline: none;
163164
}
165+
166+
span {
167+
position: absolute;
168+
left: 0;
169+
right: 0;
170+
top: 50%;
171+
transform: translateY(-50%);
172+
}
164173
}
165174

166175
&.rrt-info, &.rrt-success, &.rrt-warning, &.rrt-error {

0 commit comments

Comments
 (0)