Skip to content

Commit ab04d20

Browse files
committed
add aria-roledescription="email" and role="article" to mj-body (matches mjml 4.16.0)
1 parent c82fed6 commit ab04d20

File tree

51 files changed

+63
-56
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+63
-56
lines changed

mjml/elements/mj_body.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,18 @@ def render(self):
3838
setBackgroundColor = self.context['setBackgroundColor']
3939
setBackgroundColor(self.get_attr('background-color'))
4040

41-
lang = self.context.get('lang')
42-
html_attrs = self.html_attrs(
43-
class_=self.get_attr('css-class'),
44-
style='div',
45-
lang=lang,
46-
dir=self.context.get('dir_'),
47-
)
41+
globalData = self.context.get('globalData', {})
42+
attrs = {
43+
'aria-roledescription': 'email',
44+
'class': self.get_attr('css-class'),
45+
'style': 'div',
46+
'role': 'article',
47+
'lang': globalData.get('lang') or self.context.get('lang'),
48+
'dir': globalData.get('dir_') or self.context.get('dir_'),
49+
}
50+
title = globalData.get('title')
51+
if title:
52+
attrs['aria-label'] = title
53+
html_attrs = self.html_attrs(**attrs)
4854
children_str = self.renderChildren()
4955
return f'<div {html_attrs}>{children_str}</div>'

mjml/mjml2html.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ def setBackgroundColor(color):
184184
addComponentHeadSyle = addComponentHeadSyle,
185185
setBackgroundColor = setBackgroundColor,
186186
backgroundColor = lambda node, context: processing(node, context, applyAttributes),
187+
globalData = globalDatas,
187188
lang = mjml_lang,
188189
dir_ = mjml_dir,
189190
)

tests/testdata/button-expected.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
</head>
8484

8585
<body style="word-spacing:normal;">
86-
<div style="" lang="und" dir="auto">
86+
<div aria-roledescription="email" style="" role="article" lang="und" dir="auto">
8787
<!--[if mso | IE]><table align="center" border="0" cellpadding="0" cellspacing="0" class="" role="presentation" style="width:600px;" width="600" ><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]-->
8888
<div style="margin:0px auto;max-width:600px;">
8989
<table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="width:100%;">

tests/testdata/css-inlining-expected.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
</head>
9292

9393
<body style="word-spacing:normal;">
94-
<div style lang="und" dir="auto">
94+
<div aria-roledescription="email" style role="article" lang="und" dir="auto">
9595
<!--[if mso | IE]><table align="center" border="0" cellpadding="0" cellspacing="0" class="" role="presentation" style="width:600px;" width="600" ><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]-->
9696
<div style="margin:0px auto;max-width:600px;">
9797
<table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="width:100%;">

tests/testdata/custom-component-expected.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858

5959

6060
<div
61-
style="" lang="und" dir="auto"
61+
aria-roledescription="email" style="" role="article" lang="und" dir="auto"
6262
>
6363

6464

tests/testdata/hello-world-expected.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
</head>
8989

9090
<body style="word-spacing:normal;">
91-
<div style="" lang="und" dir="auto">
91+
<div aria-roledescription="email" style="" role="article" lang="und" dir="auto">
9292
<!--[if mso | IE]><table align="center" border="0" cellpadding="0" cellspacing="0" class="" role="presentation" style="width:600px;" width="600" ><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]-->
9393
<div style="margin:0px auto;max-width:600px;">
9494
<table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="width:100%;">

tests/testdata/html-entities-expected.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
</head>
8484

8585
<body style="word-spacing:normal;">
86-
<div style="" lang="und" dir="auto">
86+
<div aria-roledescription="email" style="" role="article" lang="und" dir="auto">
8787
<!--[if mso | IE]><table align="center" border="0" cellpadding="0" cellspacing="0" class="" role="presentation" style="width:600px;" width="600" ><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]-->
8888
<div style="margin:0px auto;max-width:600px;">
8989
<table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="width:100%;">

tests/testdata/html-without-closing-tag-expected.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
</head>
8484

8585
<body style="word-spacing:normal;">
86-
<div style="" lang="und" dir="auto">
86+
<div aria-roledescription="email" style="" role="article" lang="und" dir="auto">
8787
<!--[if mso | IE]><table align="center" border="0" cellpadding="0" cellspacing="0" class="" role="presentation" style="width:600px;" width="600" ><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]-->
8888
<div style="margin:0px auto;max-width:600px;">
8989
<table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="width:100%;">

tests/testdata/minimal-expected.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
</head>
8484

8585
<body style="word-spacing:normal;">
86-
<div style="" lang="und" dir="auto">
86+
<div aria-roledescription="email" style="" role="article" lang="und" dir="auto">
8787
<!--[if mso | IE]><table align="center" border="0" cellpadding="0" cellspacing="0" class="" role="presentation" style="width:600px;" width="600" ><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]-->
8888
<div style="margin:0px auto;max-width:600px;">
8989
<table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="width:100%;">

tests/testdata/missing-whitespace-before-tag-expected.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
</head>
8484

8585
<body style="word-spacing:normal;">
86-
<div style="" lang="und" dir="auto">
86+
<div aria-roledescription="email" style="" role="article" lang="und" dir="auto">
8787
<!--[if mso | IE]><table align="center" border="0" cellpadding="0" cellspacing="0" class="" role="presentation" style="width:600px;" width="600" ><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]-->
8888
<div style="margin:0px auto;max-width:600px;">
8989
<table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="width:100%;">

0 commit comments

Comments
 (0)