mirror of
https://github.com/facebook/react.git
synced 2026-11-18 20:15:56 +00:00
Only run custom element fixture in browsers that support it (#11052)
This commit is contained in:
1 parent
96134a0ea1
commit
ad1709a394
1 file changed
+10
-2
@@ -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>;
|
||||
@@ -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() {
|
||||
@@ -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>
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user