Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making the tables accessible #114

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions lib/componentFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = function(element) {
if (element.attr('class')) {
classes = classes.concat(element.attr('class').split(' '));
}
return format('<table class="%s"><tr><th>&nbsp;</th></tr></table>', classes.join(' '))
return format('<table class="%s" role="presentation"><tr><th>&nbsp;</th></tr></table>', classes.join(' '))

// <column>
case this.components.columns:
Expand All @@ -31,7 +31,7 @@ module.exports = function(element) {
classes = classes.concat(element.attr('class').split(' '));
}

return format('<table %s class="%s"><tbody><tr>%s</tr></tbody></table>', attrs, classes.join(' '), inner);
return format('<table %s class="%s" role="presentation"><tbody><tr>%s</tr></tbody></table>', attrs, classes.join(' '), inner);

// <button>
case this.components.button:
Expand Down Expand Up @@ -60,7 +60,7 @@ module.exports = function(element) {
classes = classes.concat(element.attr('class').split(' '));
}

return format('<table class="%s"><tbody><tr><td><table><tbody><tr><td>%s</td></tr></tbody></table></td>%s</tr></tbody></table>', classes.join(' '), inner, expander);
return format('<table class="%s" role="presentation"><tbody><tr><td><table role="presentation"><tbody><tr><td>%s</td></tr></tbody></table></td>%s</tr></tbody></table>', classes.join(' '), inner, expander);

// <container>
case this.components.container:
Expand All @@ -69,7 +69,7 @@ module.exports = function(element) {
classes = classes.concat(element.attr('class').split(' '));
}

return format('<table %s align="center" class="%s"><tbody><tr><td>%s</td></tr></tbody></table>', attrs, classes.join(' '), inner);
return format('<table %s align="center" class="%s" role="presentation"><tbody><tr><td>%s</td></tr></tbody></table>', attrs, classes.join(' '), inner);

// <inky>
case this.components.inky:
Expand All @@ -81,15 +81,15 @@ module.exports = function(element) {
if (element.attr('class')) {
classes = classes.concat(element.attr('class').split(' '));
}
return format('<table class="%s"><tbody><tr>%s</tr></tbody></table>', classes.join(' '), inner);
return format('<table class="%s" role="presentation"><tbody><tr>%s</tr></tbody></table>', classes.join(' '), inner);

// <menu>
case this.components.menu:
var classes = ['menu'];
if (element.attr('class')) {
classes = classes.concat(element.attr('class').split(' '));
}
return format('<table %s class="%s"><tbody><tr><td><table><tbody><tr>%s</tr></tbody></table></td></tr></tbody></table>', attrs, classes.join(' '), inner);
return format('<table %s class="%s" role="presentation"><tbody><tr><td><table><tbody><tr>%s</tr></tbody></table></td></tr></tbody></table>', attrs, classes.join(' '), inner);

// <item>
case this.components.menuItem:
Expand Down Expand Up @@ -125,7 +125,7 @@ module.exports = function(element) {
classes = classes.concat(element.attr('class').split(' '));
}

return format('<table %s class="callout"><tbody><tr><th class="%s">%s</th><th class="expander"></th></tr></tbody></table>', attrs, classes.join(' '), inner);
return format('<table %s class="callout" role="presentation"><tbody><tr><th class="%s">%s</th><th class="expander"></th></tr></tbody></table>', attrs, classes.join(' '), inner);

// <spacer>
case this.components.spacer:
Expand All @@ -138,15 +138,15 @@ module.exports = function(element) {
if (element.attr('size-sm') || element.attr('size-lg')) {
if (element.attr('size-sm')) {
size = (element.attr('size-sm'));
html += format('<table %s class="%s hide-for-large"><tbody><tr><td height="'+size+'px" style="font-size:'+size+'px;line-height:'+size+'px;">&nbsp;</td></tr></tbody></table>', attrs);
html += format('<table %s class="%s hide-for-large" role="presentation"><tbody><tr><td height="'+size+'px" style="font-size:'+size+'px;line-height:'+size+'px;">&nbsp;</td></tr></tbody></table>', attrs);
}
if (element.attr('size-lg')) {
size = (element.attr('size-lg'));
html += format('<table %s class="%s show-for-large"><tbody><tr><td height="'+size+'px" style="font-size:'+size+'px;line-height:'+size+'px;">&nbsp;</td></tr></tbody></table>', attrs);
html += format('<table %s class="%s show-for-large" role="presentation"><tbody><tr><td height="'+size+'px" style="font-size:'+size+'px;line-height:'+size+'px;">&nbsp;</td></tr></tbody></table>', attrs);
}
} else {
size = (element.attr('size')) || 16;
html += format('<table %s class="%s"><tbody><tr><td height="'+size+'px" style="font-size:'+size+'px;line-height:'+size+'px;">&nbsp;</td></tr></tbody></table>', attrs);
html += format('<table %s class="%s" role="presentation"><tbody><tr><td height="'+size+'px" style="font-size:'+size+'px;line-height:'+size+'px;">&nbsp;</td></tr></tbody></table>', attrs);
}

if( element.attr('size-sm') && element.attr('size-lg') ) {
Expand All @@ -162,7 +162,7 @@ module.exports = function(element) {
classes = classes.concat(element.attr('class').split(' '));
}

return format('<table %s class="%s" align="center"><tbody><tr><td class="wrapper-inner">%s</td></tr></tbody></table>', attrs, classes.join(' '), inner);
return format('<table %s class="%s" align="center" role="presentation"><tbody><tr><td class="wrapper-inner">%s</td></tr></tbody></table>', attrs, classes.join(' '), inner);

default:
// If it's not a custom component, return it as-is
Expand Down