1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-09-03 04:02:33 +02:00

Immer 9 security update (#4505)

* add yarn upgrade-interactive plugin

* chore(immer): update immer to address security issue

* Add changeset
This commit is contained in:
Dylan Schiemann
2021-09-09 22:16:50 +01:00
committed by GitHub
parent 50bb3d7e32
commit 269e59c93a
8 changed files with 416 additions and 35 deletions

View File

@@ -14,7 +14,7 @@
"dist/"
],
"dependencies": {
"immer": "^8.0.1",
"immer": "^9.0.6",
"is-plain-object": "^5.0.0",
"tiny-warning": "^1.0.3"
},

View File

@@ -344,7 +344,7 @@ export const Path: PathInterface = {
*/
transform(
path: Path,
path: Path | null,
operation: Operation,
options: { affinity?: 'forward' | 'backward' | null } = {}
): Path | null {
@@ -352,10 +352,14 @@ export const Path: PathInterface = {
const { affinity = 'forward' } = options
// PERF: Exit early if the operation is guaranteed not to have an effect.
if (path.length === 0) {
if (!path || path?.length === 0) {
return
}
if (p === null) {
return null
}
switch (operation.type) {
case 'insert_node': {
const { path: op } = operation

View File

@@ -91,11 +91,14 @@ export const Point: PointInterface = {
*/
transform(
point: Point,
point: Point | null,
op: Operation,
options: { affinity?: 'forward' | 'backward' | null } = {}
): Point | null {
return produce(point, p => {
if (p === null) {
return null
}
const { affinity = 'forward' } = options
const { path, offset } = p

View File

@@ -207,38 +207,40 @@ export const Range: RangeInterface = {
*/
transform(
range: Range,
range: Range | null,
op: Operation,
options: {
affinity?: 'forward' | 'backward' | 'outward' | 'inward' | null
} = {}
): Range | null {
const { affinity = 'inward' } = options
let affinityAnchor: 'forward' | 'backward' | null
let affinityFocus: 'forward' | 'backward' | null
if (affinity === 'inward') {
if (Range.isForward(range)) {
affinityAnchor = 'forward'
affinityFocus = 'backward'
} else {
affinityAnchor = 'backward'
affinityFocus = 'forward'
}
} else if (affinity === 'outward') {
if (Range.isForward(range)) {
affinityAnchor = 'backward'
affinityFocus = 'forward'
} else {
affinityAnchor = 'forward'
affinityFocus = 'backward'
}
} else {
affinityAnchor = affinity
affinityFocus = affinity
}
return produce(range, r => {
if (r === null) {
return null
}
const { affinity = 'inward' } = options
let affinityAnchor: 'forward' | 'backward' | null
let affinityFocus: 'forward' | 'backward' | null
if (affinity === 'inward') {
if (Range.isForward(r)) {
affinityAnchor = 'forward'
affinityFocus = 'backward'
} else {
affinityAnchor = 'backward'
affinityFocus = 'forward'
}
} else if (affinity === 'outward') {
if (Range.isForward(r)) {
affinityAnchor = 'backward'
affinityFocus = 'forward'
} else {
affinityAnchor = 'forward'
affinityFocus = 'backward'
}
} else {
affinityAnchor = affinity
affinityFocus = affinity
}
const anchor = Point.transform(r.anchor, op, { affinity: affinityAnchor })
const focus = Point.transform(r.focus, op, { affinity: affinityFocus })