From 0b3b55cde25c1d4404dfe0097674a9931c54b6d5 Mon Sep 17 00:00:00 2001 From: Philippe Duval Date: Wed, 1 Aug 2018 16:55:05 -0400 Subject: [PATCH] Add meta http-equiv for ie compatibility to the index by default. --- dash/dash.py | 9 +++++++-- tests/test_integration.py | 14 +++++++------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/dash/dash.py b/dash/dash.py index 44fad1efee..7b88894383 100644 --- a/dash/dash.py +++ b/dash/dash.py @@ -339,16 +339,21 @@ 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('') if not has_charset: - tags.append('') + tags.append('') for meta in self._meta_tags: attributes = [] for k, v in meta.items(): attributes.append('{}="{}"'.format(k, v)) - tags.append(''.format(' '.join(attributes))) + tags.append(''.format(' '.join(attributes))) return '\n '.join(tags) diff --git a/tests/test_integration.py b/tests/test_integration.py index 770b9152cb..b04675195b 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -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) @@ -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'])