Skip to content

Commit

Permalink
Only run custom element fixture in browsers that support it (#11052)
Browse files Browse the repository at this point in the history
  • Loading branch information
aweary committed Oct 2, 2017
1 parent 96134a0 commit ad1709a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions fixtures/dom/src/components/fixtures/custom-elements/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import TestCase from '../../TestCase';
const React = window.React;
const ReactDOM = window.ReactDOM;

const supportsCustomElements = typeof customElements !== 'undefined';

class HelloWorld extends React.Component {
render() {
return <h1>Hello, world!</h1>;
Expand All @@ -27,7 +29,9 @@ return class MyElement extends HTMLElement {
}`
)(React, ReactDOM, HelloWorld);

customElements.define('my-element', MyElement);
if (supportsCustomElements) {
customElements.define('my-element', MyElement);
}

export default class ButtonTestCases extends React.Component {
render() {
Expand All @@ -39,7 +43,11 @@ export default class ButtonTestCases extends React.Component {
<TestCase.ExpectedResult>
You should see "Hello, World" printed below.{' '}
</TestCase.ExpectedResult>
<my-element />
{supportsCustomElements
? <my-element />
: <div>
This browser does not support custom elements.
</div>}
</TestCase>
</FixtureSet>
);
Expand Down

0 comments on commit ad1709a

Please sign in to comment.