@fluidframework/sequence 0.59.4000 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +1 -1
- package/dist/intervalCollection.d.ts +21 -0
- package/dist/intervalCollection.d.ts.map +1 -1
- package/dist/intervalCollection.js +123 -37
- package/dist/intervalCollection.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/sequence.d.ts +2 -2
- package/dist/sequence.d.ts.map +1 -1
- package/dist/sequence.js +6 -6
- package/dist/sequence.js.map +1 -1
- package/dist/sharedIntervalCollection.js +1 -1
- package/dist/sharedIntervalCollection.js.map +1 -1
- package/lib/intervalCollection.d.ts +21 -0
- package/lib/intervalCollection.d.ts.map +1 -1
- package/lib/intervalCollection.js +124 -38
- package/lib/intervalCollection.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/sequence.d.ts +2 -2
- package/lib/sequence.d.ts.map +1 -1
- package/lib/sequence.js +7 -7
- package/lib/sequence.js.map +1 -1
- package/lib/sharedIntervalCollection.js +1 -1
- package/lib/sharedIntervalCollection.js.map +1 -1
- package/package.json +39 -40
- package/src/intervalCollection.ts +143 -45
- package/src/packageVersion.ts +1 -1
- package/src/sequence.ts +19 -17
- package/src/sharedIntervalCollection.ts +1 -1
package/.eslintrc.js
CHANGED
|
@@ -10,7 +10,17 @@ import { IValueFactory, IValueOpEmitter, IValueOperation, IValueType } from "./d
|
|
|
10
10
|
export declare enum IntervalType {
|
|
11
11
|
Simple = 0,
|
|
12
12
|
Nest = 1,
|
|
13
|
+
/**
|
|
14
|
+
* SlideOnRemove indicates that the ends of the interval will slide if the segment
|
|
15
|
+
* they reference is removed and acked.
|
|
16
|
+
* See `packages\dds\merge-tree\REFERENCEPOSITIONS.md` for details
|
|
17
|
+
* SlideOnRemove is the default interval behavior and does not need to be specified.
|
|
18
|
+
*/
|
|
13
19
|
SlideOnRemove = 2,
|
|
20
|
+
/**
|
|
21
|
+
* @internal
|
|
22
|
+
* A temporary interval, used internally
|
|
23
|
+
*/
|
|
14
24
|
Transient = 4
|
|
15
25
|
}
|
|
16
26
|
export interface ISerializedInterval {
|
|
@@ -145,6 +155,14 @@ export declare class IntervalCollection<TInterval extends ISerializableInterval>
|
|
|
145
155
|
constructor(helpers: IIntervalHelpers<TInterval>, requiresClient: boolean, emitter: IValueOpEmitter, serializedIntervals: ISerializedInterval[]);
|
|
146
156
|
attachGraph(client: Client, label: string): void;
|
|
147
157
|
getIntervalById(id: string): TInterval;
|
|
158
|
+
/**
|
|
159
|
+
* Create a new interval and add it to the collection
|
|
160
|
+
* @param start - interval start position
|
|
161
|
+
* @param end - interval end position
|
|
162
|
+
* @param intervalType - type of the interval. All intervals are SlideOnRemove. Intervals may not be Transient.
|
|
163
|
+
* @param props - properties of the interval
|
|
164
|
+
* @returns - the created interval
|
|
165
|
+
*/
|
|
148
166
|
add(start: number, end: number, intervalType: IntervalType, props?: PropertySet): TInterval;
|
|
149
167
|
private deleteExistingInterval;
|
|
150
168
|
removeIntervalById(id: string): TInterval;
|
|
@@ -162,6 +180,9 @@ export declare class IntervalCollection<TInterval extends ISerializableInterval>
|
|
|
162
180
|
ackChange(serializedInterval: ISerializedInterval, local: boolean, op: ISequencedDocumentMessage): void;
|
|
163
181
|
addConflictResolver(conflictResolver: IntervalConflictResolver<TInterval>): void;
|
|
164
182
|
attachDeserializer(onDeserialize: DeserializeCallback): void;
|
|
183
|
+
private getSlideToSegment;
|
|
184
|
+
private setSlideOnRemove;
|
|
185
|
+
private ackInterval;
|
|
165
186
|
/** @deprecated - use ackAdd */
|
|
166
187
|
addInternal(serializedInterval: ISerializedInterval, local: boolean, op: ISequencedDocumentMessage): TInterval;
|
|
167
188
|
/** @internal */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intervalCollection.d.ts","sourceRoot":"","sources":["../src/intervalCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAU,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"intervalCollection.d.ts","sourceRoot":"","sources":["../src/intervalCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAU,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAE5D,OAAO,EAEH,MAAM,EAGN,YAAY,EACZ,SAAS,EACT,wBAAwB,EAIxB,cAAc,EAEd,iBAAiB,EACjB,WAAW,EAMd,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AAEjF,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAIrG,oBAAY,YAAY;IACpB,MAAM,IAAM;IACZ,IAAI,IAAM;IACV;;;;;OAKG;IACH,aAAa,IAAM;IACnB;;;OAGG;IACH,SAAS,IAAM;CAClB;AAED,MAAM,WAAW,mBAAmB;IAChC,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,EAAE,YAAY,CAAC;IAC3B,UAAU,CAAC,EAAE,WAAW,CAAC;CAC5B;AAED,MAAM,WAAW,qBAAsB,SAAQ,SAAS;IACpD,UAAU,EAAE,WAAW,CAAC;IACxB,eAAe,EAAE,iBAAiB,CAAC;IACnC,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,mBAAmB,CAAC;IAC/C,aAAa,CAAC,KAAK,EAAE,WAAW,EAAE,aAAa,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EAAE,EAAE,yBAAyB;IAIjC,gBAAgB;IACT,MAAM,CACT,kBAAkB,EAAE,mBAAmB,EACvC,KAAK,EAAE,OAAO,EACd,EAAE,EAAE,yBAAyB;IAmCjC,kCAAkC;IAC3B,cAAc,CACjB,kBAAkB,EAAE,mBAAmB,EACvC,KAAK,EAAE,OAAO,EACd,EAAE,EAAE,yBAAyB,GAAG,IAAI;IAIxC,gBAAgB;IACT,SAAS,CACZ,kBAAkB,EAAE,mBAAmB,EACvC,KAAK,EAAE,OAAO,EACd,EAAE,EAAE,yBAAyB,GAAG,IAAI;IAmBjC,iBAAiB;IAQjB,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,0BAA0B,CAAC,SAAS,CAAC;IAK1D,sCAAsC,CAAC,aAAa,EAAE,MAAM,GAAG,0BAA0B,CAAC,SAAS,CAAC;IAKpG,uCAAuC,CAAC,aAAa,EAAE,MAAM,GAAG,0BAA0B,CAAC,SAAS,CAAC;IAKrG,oCAAoC,CAAC,WAAW,EAAE,MAAM,GAAG,0BAA0B,CAAC,SAAS,CAAC;IAKhG,qCAAqC,CAAC,WAAW,EAAE,MAAM,GAAG,0BAA0B,CAAC,SAAS,CAAC;IAKjG,sBAAsB,CACzB,OAAO,EAAE,SAAS,EAAE,EACpB,eAAe,EAAE,OAAO,EACxB,KAAK,CAAC,EAAE,MAAM,EACd,GAAG,CAAC,EAAE,MAAM;IAQT,wBAAwB,CAAC,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,SAAS,EAAE;IAQjF,GAAG,CAAC,EAAE,EAAE,CAAC,QAAQ,EAAE,SAAS,KAAK,IAAI;IAQrC,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS;IAQxC,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS;CAO9C"}
|
|
@@ -18,6 +18,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
18
18
|
exports.IntervalCollection = exports.IntervalCollectionIterator = exports.IntervalCollectionValueType = exports.SequenceIntervalCollectionValueType = exports.LocalIntervalCollection = exports.createIntervalIndex = exports.defaultIntervalConflictResolver = exports.SequenceInterval = exports.Interval = exports.IntervalType = void 0;
|
|
19
19
|
/* eslint-disable no-bitwise */
|
|
20
20
|
const common_utils_1 = require("@fluidframework/common-utils");
|
|
21
|
+
const container_utils_1 = require("@fluidframework/container-utils");
|
|
21
22
|
const merge_tree_1 = require("@fluidframework/merge-tree");
|
|
22
23
|
const uuid_1 = require("uuid");
|
|
23
24
|
const reservedIntervalIdKey = "intervalId";
|
|
@@ -25,7 +26,17 @@ var IntervalType;
|
|
|
25
26
|
(function (IntervalType) {
|
|
26
27
|
IntervalType[IntervalType["Simple"] = 0] = "Simple";
|
|
27
28
|
IntervalType[IntervalType["Nest"] = 1] = "Nest";
|
|
29
|
+
/**
|
|
30
|
+
* SlideOnRemove indicates that the ends of the interval will slide if the segment
|
|
31
|
+
* they reference is removed and acked.
|
|
32
|
+
* See `packages\dds\merge-tree\REFERENCEPOSITIONS.md` for details
|
|
33
|
+
* SlideOnRemove is the default interval behavior and does not need to be specified.
|
|
34
|
+
*/
|
|
28
35
|
IntervalType[IntervalType["SlideOnRemove"] = 2] = "SlideOnRemove";
|
|
36
|
+
/**
|
|
37
|
+
* @internal
|
|
38
|
+
* A temporary interval, used internally
|
|
39
|
+
*/
|
|
29
40
|
IntervalType[IntervalType["Transient"] = 4] = "Transient";
|
|
30
41
|
})(IntervalType = exports.IntervalType || (exports.IntervalType = {}));
|
|
31
42
|
class Interval {
|
|
@@ -234,46 +245,66 @@ class SequenceInterval {
|
|
|
234
245
|
}
|
|
235
246
|
}
|
|
236
247
|
exports.SequenceInterval = SequenceInterval;
|
|
237
|
-
function
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
248
|
+
function createPositionReferenceFromSegoff(client, segoff, refType, op) {
|
|
249
|
+
if (segoff.segment) {
|
|
250
|
+
const ref = client.createLocalReferencePosition(segoff.segment, segoff.offset, refType, undefined);
|
|
251
|
+
return ref;
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
if (!op && !(0, merge_tree_1.refTypeIncludesFlag)(refType, merge_tree_1.ReferenceType.Transient)) {
|
|
255
|
+
throw new container_utils_1.UsageError("Non-transient references need segment");
|
|
243
256
|
}
|
|
244
|
-
return
|
|
257
|
+
return new merge_tree_1.LocalReference(client, undefined, 0, refType);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
function createPositionReference(client, pos, refType, op) {
|
|
261
|
+
let segoff;
|
|
262
|
+
if (op) {
|
|
263
|
+
(0, common_utils_1.assert)((refType & merge_tree_1.ReferenceType.SlideOnRemove) !== 0, 0x2f5 /* op create references must be SlideOnRemove */);
|
|
264
|
+
segoff = client.getContainingSegment(pos, op);
|
|
265
|
+
segoff = client.getSlideToSegment(segoff);
|
|
266
|
+
}
|
|
267
|
+
else {
|
|
268
|
+
(0, common_utils_1.assert)((refType & merge_tree_1.ReferenceType.SlideOnRemove) === 0, 0x2f6 /* SlideOnRemove references must be op created */);
|
|
269
|
+
segoff = client.getContainingSegment(pos);
|
|
245
270
|
}
|
|
246
|
-
return
|
|
271
|
+
return createPositionReferenceFromSegoff(client, segoff, refType, op);
|
|
247
272
|
}
|
|
248
273
|
function createSequenceInterval(label, start, end, client, intervalType, op) {
|
|
249
274
|
let beginRefType = merge_tree_1.ReferenceType.RangeBegin;
|
|
250
275
|
let endRefType = merge_tree_1.ReferenceType.RangeEnd;
|
|
251
|
-
if (intervalType === IntervalType.
|
|
252
|
-
beginRefType = merge_tree_1.ReferenceType.NestBegin;
|
|
253
|
-
endRefType = merge_tree_1.ReferenceType.NestEnd;
|
|
254
|
-
}
|
|
255
|
-
else if (intervalType === IntervalType.Transient) {
|
|
276
|
+
if (intervalType === IntervalType.Transient) {
|
|
256
277
|
beginRefType = merge_tree_1.ReferenceType.Transient;
|
|
257
278
|
endRefType = merge_tree_1.ReferenceType.Transient;
|
|
258
279
|
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
280
|
+
else {
|
|
281
|
+
if (intervalType === IntervalType.Nest) {
|
|
282
|
+
beginRefType = merge_tree_1.ReferenceType.NestBegin;
|
|
283
|
+
endRefType = merge_tree_1.ReferenceType.NestEnd;
|
|
284
|
+
}
|
|
285
|
+
// All non-transient interval references must eventually be SlideOnRemove
|
|
286
|
+
// To ensure eventual consistency, they must start as StayOnRemove when
|
|
287
|
+
// pending (created locally and creation op is not acked)
|
|
288
|
+
if (op) {
|
|
289
|
+
beginRefType |= merge_tree_1.ReferenceType.SlideOnRemove;
|
|
290
|
+
endRefType |= merge_tree_1.ReferenceType.SlideOnRemove;
|
|
291
|
+
}
|
|
292
|
+
else {
|
|
293
|
+
beginRefType |= merge_tree_1.ReferenceType.StayOnRemove;
|
|
294
|
+
endRefType |= merge_tree_1.ReferenceType.StayOnRemove;
|
|
295
|
+
}
|
|
263
296
|
}
|
|
264
297
|
const startLref = createPositionReference(client, start, beginRefType, op);
|
|
265
298
|
const endLref = createPositionReference(client, end, endRefType, op);
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
return ival;
|
|
276
|
-
}
|
|
299
|
+
startLref.pairedRef = endLref;
|
|
300
|
+
endLref.pairedRef = startLref;
|
|
301
|
+
const rangeProp = {
|
|
302
|
+
[merge_tree_1.reservedRangeLabelsKey]: [label],
|
|
303
|
+
};
|
|
304
|
+
startLref.addProperties(rangeProp);
|
|
305
|
+
endLref.addProperties(rangeProp);
|
|
306
|
+
const ival = new SequenceInterval(startLref, endLref, intervalType, rangeProp);
|
|
307
|
+
return ival;
|
|
277
308
|
}
|
|
278
309
|
function defaultIntervalConflictResolver(a, b) {
|
|
279
310
|
a.addPropertySet(b.properties);
|
|
@@ -405,14 +436,12 @@ class LocalIntervalCollection {
|
|
|
405
436
|
}
|
|
406
437
|
}
|
|
407
438
|
findOverlappingIntervals(startPosition, endPosition) {
|
|
408
|
-
if (
|
|
409
|
-
const transientInterval = this.helpers.create("transient", startPosition, endPosition, this.client, IntervalType.Transient);
|
|
410
|
-
const overlappingIntervalNodes = this.intervalTree.match(transientInterval);
|
|
411
|
-
return overlappingIntervalNodes.map((node) => node.key);
|
|
412
|
-
}
|
|
413
|
-
else {
|
|
439
|
+
if (endPosition < startPosition || this.intervalTree.intervals.isEmpty()) {
|
|
414
440
|
return [];
|
|
415
441
|
}
|
|
442
|
+
const transientInterval = this.helpers.create("transient", startPosition, endPosition, this.client, IntervalType.Transient);
|
|
443
|
+
const overlappingIntervalNodes = this.intervalTree.match(transientInterval);
|
|
444
|
+
return overlappingIntervalNodes.map((node) => node.key);
|
|
416
445
|
}
|
|
417
446
|
previousInterval(pos) {
|
|
418
447
|
const transientInterval = this.helpers.create("transient", pos, pos, this.client, IntervalType.Transient);
|
|
@@ -664,11 +693,22 @@ class IntervalCollection extends common_utils_1.TypedEventEmitter {
|
|
|
664
693
|
}
|
|
665
694
|
return this.localCollection.getIntervalById(id);
|
|
666
695
|
}
|
|
696
|
+
/**
|
|
697
|
+
* Create a new interval and add it to the collection
|
|
698
|
+
* @param start - interval start position
|
|
699
|
+
* @param end - interval end position
|
|
700
|
+
* @param intervalType - type of the interval. All intervals are SlideOnRemove. Intervals may not be Transient.
|
|
701
|
+
* @param props - properties of the interval
|
|
702
|
+
* @returns - the created interval
|
|
703
|
+
*/
|
|
667
704
|
add(start, end, intervalType, props) {
|
|
668
705
|
var _a, _b;
|
|
669
706
|
if (!this.attached) {
|
|
670
707
|
throw new Error("attach must be called prior to adding intervals");
|
|
671
708
|
}
|
|
709
|
+
if (intervalType & IntervalType.Transient) {
|
|
710
|
+
throw new Error("Can not add transient intervals");
|
|
711
|
+
}
|
|
672
712
|
const interval = this.localCollection.addInterval(start, end, intervalType, props);
|
|
673
713
|
if (interval) {
|
|
674
714
|
const serializedInterval = {
|
|
@@ -827,13 +867,15 @@ class IntervalCollection extends common_utils_1.TypedEventEmitter {
|
|
|
827
867
|
// This is an ack from the server. Remove the pending change.
|
|
828
868
|
this.removePendingChange(serializedInterval);
|
|
829
869
|
const id = serializedInterval.properties[reservedIntervalIdKey];
|
|
870
|
+
// Could store the interval in the localOpMetadata to avoid the getIntervalById call
|
|
830
871
|
interval = this.getIntervalById(id);
|
|
831
872
|
if (interval) {
|
|
832
873
|
// Let the propertyManager prune its pending change-properties set.
|
|
833
874
|
(_a = interval.propertyManager) === null || _a === void 0 ? void 0 : _a.ackPendingProperties({
|
|
834
|
-
type:
|
|
875
|
+
type: merge_tree_1.MergeTreeDeltaType.ANNOTATE,
|
|
835
876
|
props: serializedInterval.properties,
|
|
836
877
|
});
|
|
878
|
+
this.ackInterval(interval, op);
|
|
837
879
|
}
|
|
838
880
|
}
|
|
839
881
|
else {
|
|
@@ -888,6 +930,46 @@ class IntervalCollection extends common_utils_1.TypedEventEmitter {
|
|
|
888
930
|
this.onDeserialize(interval);
|
|
889
931
|
});
|
|
890
932
|
}
|
|
933
|
+
getSlideToSegment(lref) {
|
|
934
|
+
const segoff = { segment: lref.segment, offset: lref.offset };
|
|
935
|
+
const newSegoff = this.client.getSlideToSegment(segoff);
|
|
936
|
+
const value = (segoff === newSegoff) ? undefined : newSegoff;
|
|
937
|
+
return value;
|
|
938
|
+
}
|
|
939
|
+
setSlideOnRemove(lref) {
|
|
940
|
+
let refType = lref.refType;
|
|
941
|
+
refType = refType & ~merge_tree_1.ReferenceType.StayOnRemove;
|
|
942
|
+
refType = refType | merge_tree_1.ReferenceType.SlideOnRemove;
|
|
943
|
+
lref.refType = refType;
|
|
944
|
+
}
|
|
945
|
+
ackInterval(interval, op) {
|
|
946
|
+
// in current usage, interval is always a SequenceInterval
|
|
947
|
+
if (!(interval instanceof SequenceInterval)) {
|
|
948
|
+
return;
|
|
949
|
+
}
|
|
950
|
+
if (!(0, merge_tree_1.refTypeIncludesFlag)(interval.start, merge_tree_1.ReferenceType.StayOnRemove)) {
|
|
951
|
+
return;
|
|
952
|
+
}
|
|
953
|
+
(0, common_utils_1.assert)((0, merge_tree_1.refTypeIncludesFlag)(interval.end, merge_tree_1.ReferenceType.StayOnRemove), 0x2f7 /* start and end must both be StayOnRemove */);
|
|
954
|
+
const newStart = this.getSlideToSegment(interval.start);
|
|
955
|
+
const newEnd = this.getSlideToSegment(interval.end);
|
|
956
|
+
this.setSlideOnRemove(interval.start);
|
|
957
|
+
this.setSlideOnRemove(interval.end);
|
|
958
|
+
if (newStart || newEnd) {
|
|
959
|
+
this.localCollection.removeExistingInterval(interval);
|
|
960
|
+
if (newStart) {
|
|
961
|
+
const props = interval.start.properties;
|
|
962
|
+
interval.start = createPositionReferenceFromSegoff(this.client, newStart, interval.start.refType, op);
|
|
963
|
+
interval.start.addProperties(props);
|
|
964
|
+
}
|
|
965
|
+
if (newEnd) {
|
|
966
|
+
const props = interval.end.properties;
|
|
967
|
+
interval.end = createPositionReferenceFromSegoff(this.client, newEnd, interval.end.refType, op);
|
|
968
|
+
interval.end.addProperties(props);
|
|
969
|
+
}
|
|
970
|
+
this.localCollection.add(interval);
|
|
971
|
+
}
|
|
972
|
+
}
|
|
891
973
|
/** @deprecated - use ackAdd */
|
|
892
974
|
addInternal(serializedInterval, local, op) {
|
|
893
975
|
return this.ackAdd(serializedInterval, local, op);
|
|
@@ -895,8 +977,12 @@ class IntervalCollection extends common_utils_1.TypedEventEmitter {
|
|
|
895
977
|
/** @internal */
|
|
896
978
|
ackAdd(serializedInterval, local, op) {
|
|
897
979
|
if (local) {
|
|
898
|
-
|
|
899
|
-
//
|
|
980
|
+
const id = serializedInterval.properties[reservedIntervalIdKey];
|
|
981
|
+
// Could store the interval in the localOpMetadata to avoid the getIntervalById call
|
|
982
|
+
const localInterval = this.getIntervalById(id);
|
|
983
|
+
if (localInterval) {
|
|
984
|
+
this.ackInterval(localInterval, op);
|
|
985
|
+
}
|
|
900
986
|
return;
|
|
901
987
|
}
|
|
902
988
|
if (!this.attached) {
|