Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

Commit

Permalink
fix(chore): fixes webpack-stream error with missing catch var declara…
Browse files Browse the repository at this point in the history
…tion (#2291)

Summary:
**Summary**

Fixes an error thrown by `webpack-stream` with the missing catch var declaration
```
[16:12:34] '<anonymous>' errored after 8.42 s
[16:12:34] Error in plugin "webpack-stream"
Message:
    ./lib/setDraftEditorSelection.js
Module parse failed: Unexpected token (278:12)
You may need an appropriate loader to handle this file type.
|     try {
|       selection.addRange(range);
|     } catch {// ignore
|     }
|   } else {
 @ ./lib/DraftEditorLeaf.react.js 29:30-66
 @ ./lib/DraftEditorBlock.react.js
 @ ./lib/Draft.js
Details:
    domain: [object Object]
    domainThrown: true

```

**Test Plan**
```
yarn
```
Build completes without errors
Pull Request resolved: #2291

Reviewed By: mrkev

Differential Revision: D19230824

Pulled By: claudiopro

fbshipit-source-id: 9fdc2ebbee654404458851f6fd14a367c33a23e4
  • Loading branch information
Claudio Procida authored and facebook-github-bot committed Jan 2, 2020
1 parent 64b51df commit 4252469
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion meta/bundle-size-stats/Draft.js.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion meta/bundle-size-stats/Draft.min.js.json

Large diffs are not rendered by default.

13 changes: 8 additions & 5 deletions src/component/selection/setDraftEditorSelection.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ function addFocusToSelection(
// the call to 'selection.extend' is about to throw
DraftJsDebugLogging.logSelectionStateFailure({
anonymizedDom: getAnonymizedEditorDOM(node),
extraParams: JSON.stringify({offset: offset}),
extraParams: JSON.stringify({offset}),
selectionState: JSON.stringify(selectionState.toJS()),
});
}
Expand Down Expand Up @@ -292,7 +292,7 @@ function addFocusToSelection(
: null,
selectionFocusOffset: selection.focusOffset,
message: e ? '' + e : null,
offset: offset,
offset,
},
null,
2,
Expand Down Expand Up @@ -329,7 +329,7 @@ function addPointToSelection(
// in this case we know that the call to 'range.setStart' is about to throw
DraftJsDebugLogging.logSelectionStateFailure({
anonymizedDom: getAnonymizedEditorDOM(node),
extraParams: JSON.stringify({offset: offset}),
extraParams: JSON.stringify({offset}),
selectionState: JSON.stringify(selectionState.toJS()),
});
DraftEffects.handleExtensionCausedError();
Expand All @@ -340,8 +340,11 @@ function addPointToSelection(
if (isIE) {
try {
selection.addRange(range);
} catch {
// ignore
} catch (e) {
if (__DEV__) {
/* eslint-disable-next-line no-console */
console.warn('Call to selection.addRange() threw exception: ', e);
}
}
} else {
selection.addRange(range);
Expand Down

0 comments on commit 4252469

Please sign in to comment.