Skip to content

Commit

Permalink
Add meta http-equiv for ie compatibility to the index by default.
Browse files Browse the repository at this point in the history
  • Loading branch information
T4rk1n committed Aug 1, 2018
1 parent 54ca4a3 commit f6797db
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
5 changes: 5 additions & 0 deletions dash/dash.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,14 @@ def _generate_config_html(self):
).format(json.dumps(self._config()))

def _generate_meta_html(self):
has_ie_compat = any(
x.get('http-equiv', '') == 'X-UA-Compatible'
for x in self._meta_tags)
has_charset = any('charset' in x for x in self._meta_tags)

tags = []
if not has_ie_compat:
tags.append('<meta equiv="X-UA-Compatible" content="IE=edge"/>')
if not has_charset:
tags.append('<meta charset="UTF-8"/>')
for meta in self._meta_tags:
Expand Down
14 changes: 7 additions & 7 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,10 @@ def display_output(react_value, flow_value):
self.percy_snapshot(name='flowtype')

def test_meta_tags(self):
metas = (
metas = [
{'name': 'description', 'content': 'my dash app'},
{'name': 'custom', 'content': 'customized'}
)
{'name': 'custom', 'content': 'customized'},
]

app = dash.Dash(meta_tags=metas)

Expand All @@ -285,12 +285,12 @@ def test_meta_tags(self):

meta = self.driver.find_elements_by_tag_name('meta')

# -1 for the meta charset.
self.assertEqual(len(metas), len(meta) - 1, 'Not enough meta tags')
# -2 for the meta charset and http-equiv.
self.assertEqual(len(metas), len(meta) - 2, 'Not enough meta tags')

for i in range(1, len(meta)):
for i in range(2, len(meta)):
meta_tag = meta[i]
meta_info = metas[i - 1]
meta_info = metas[i - 2]
name = meta_tag.get_attribute('name')
content = meta_tag.get_attribute('content')
self.assertEqual(name, meta_info['name'])
Expand Down

0 comments on commit f6797db

Please sign in to comment.