Skip to content

Commit

Permalink
Run prettier on new selection events fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon Dail committed Feb 12, 2018
1 parent 0003681 commit fef8519
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 32 deletions.
22 changes: 10 additions & 12 deletions fixtures/dom/src/components/Iframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const ReactDOM = window.ReactDOM;
class IframePortal extends React.Component {
state = {ref: null};

handleRef = (ref) => {
handleRef = ref => {
if (ref !== this.state.ref) {
this.setState({ref});
if (ref && ref.contentDocument && this.props.head) {
Expand All @@ -19,15 +19,16 @@ class IframePortal extends React.Component {
if (ref && ref.contentDocument) {
portal = ReactDOM.createPortal(
this.props.children,
ref.contentDocument.body,
ref.contentDocument.body
);
}

return (
<div>
<iframe
style={{ border: 'none', height: this.props.height }}
ref={this.handleRef} />
style={{border: 'none', height: this.props.height}}
ref={this.handleRef}
/>
{portal}
</div>
);
Expand All @@ -38,16 +39,13 @@ class IframeSubtree extends React.Component {
warned = false;
render() {
if (!this.warned) {
console.error(`IFrame has not yet been implemented for React v${React.version}`);
console.error(
`IFrame has not yet been implemented for React v${React.version}`
);
this.warned = true;
}
return (
<div>
{this.props.children}
</div>
)
return <div>{this.props.children}</div>;
}
}


export default ReactDOM.createPortal ? IframePortal : IframeSubtree;
export default (ReactDOM.createPortal ? IframePortal : IframeSubtree);
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ import Iframe from '../../Iframe';
const React = window.React;
const {EditorState, Editor} = window.Draft;


export default class DraftJsEditorTestCase extends React.Component {
constructor(props) {
super(props);
this.state = {editorState: EditorState.createEmpty()};
this.onChange = (editorState) => this.setState({editorState});
this.onChange = editorState => this.setState({editorState});
}
render() {
return (
Expand All @@ -19,15 +18,20 @@ export default class DraftJsEditorTestCase extends React.Component {
works in an iframe.">
<TestCase.Steps>
<li>Enter some text into the Draft.js editor (grey outlined box)</li>
<li>Change your cursor position to somewhere in the middle of the text</li>
<li>
Change your cursor position to somewhere in the middle of the text
</li>
<li>Enter a new character</li>
</TestCase.Steps>
<TestCase.ExpectedResult>
The cursor should not jump positions
</TestCase.ExpectedResult>
<Iframe height={60}>
<div style={{ border: '1px solid grey' }}>
<Editor editorState={this.state.editorState} onChange={this.onChange} />
<div style={{border: '1px solid grey'}}>
<Editor
editorState={this.state.editorState}
onChange={this.onChange}
/>
</div>
</Iframe>
</TestCase>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ import Iframe from '../../Iframe';
const React = window.React;

export default class ReorderedInputsTestCase extends React.Component {

state = { count: 0 };
state = {count: 0};

componentDidMount() {
this.interval = setInterval(() => {
this.setState({ count: this.state.count + 1 });
this.setState({count: this.state.count + 1});
}, 2000);
}

Expand All @@ -29,9 +28,7 @@ export default class ReorderedInputsTestCase extends React.Component {

render() {
return (
<TestCase
title="Reordered input elements in iframes"
description="">
<TestCase title="Reordered input elements in iframes" description="">
<TestCase.Steps>
<li>The two inputs below swap positions every two seconds</li>
<li>Select the text in either of them</li>
Expand All @@ -40,10 +37,8 @@ export default class ReorderedInputsTestCase extends React.Component {
<TestCase.ExpectedResult>
The selection you made should be maintained
</TestCase.ExpectedResult>
<Iframe height={50}>
{this.renderInputs()}
</Iframe>
<Iframe height={50}>{this.renderInputs()}</Iframe>
</TestCase>
)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import ReorderedInputsTestCase from './ReorderedInputsTestCase';
import DraftJsEditorTestCase from './DraftJsEditorTestCase';
const React = window.React;


export default function SelectionEvents() {
return (
<FixtureSet
Expand All @@ -21,4 +20,4 @@ export default function SelectionEvents() {
<DraftJsEditorTestCase />
</FixtureSet>
);
};
}
6 changes: 3 additions & 3 deletions fixtures/dom/src/react-loader.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import semver from 'semver'
import semver from 'semver';

/**
* Take a version from the window query string and load a specific
Expand Down Expand Up @@ -41,14 +41,14 @@ export default function loadReact() {
// @TODO We're using a build of draft-js provided by @acusti in https://github.com/facebook/react/pull/12037
// This is because currently draft doesn't support iframes. This should be changed back to the official
// release on unpkg once the draft fixes are merged.
const DRAFT_JS_PATH = 'https://cdn.rawgit.com/brandcast/draft-js-built/d6c2ffc64914b001411356c0bfab24e831bc5429/dist/Draft.js';
const DRAFT_JS_PATH =
'https://cdn.rawgit.com/brandcast/draft-js-built/d6c2ffc64914b001411356c0bfab24e831bc5429/dist/Draft.js';
let REACT_PATH = 'react.development.js';
let DOM_PATH = 'react-dom.development.js';

let query = parseQuery(window.location.search);
let version = query.version || 'local';


if (version !== 'local') {
const {major, minor, prerelease} = semver(version);
const [preReleaseStage, preReleaseVersion] = prerelease;
Expand Down

0 comments on commit fef8519

Please sign in to comment.