diff --git a/packages/core/src/Extension.ts b/packages/core/src/Extension.ts index aa3ec5a5..e30fe36c 100644 --- a/packages/core/src/Extension.ts +++ b/packages/core/src/Extension.ts @@ -254,11 +254,13 @@ export class Extension { } configure(options: Partial = {}) { - this.options = mergeDeep(this.options, options) as Options - // return a new instance so we can use the same extension // with different calls of `configure` - return this.extend() + const extension = this.extend() + + extension.options = mergeDeep(this.options, options) as Options + + return extension } extend(extendedConfig: Partial> = {}) { diff --git a/packages/core/src/Mark.ts b/packages/core/src/Mark.ts index 71f23ac9..02dc59b9 100644 --- a/packages/core/src/Mark.ts +++ b/packages/core/src/Mark.ts @@ -351,11 +351,13 @@ export class Mark { } configure(options: Partial = {}) { - this.options = mergeDeep(this.options, options) as Options - // return a new instance so we can use the same extension // with different calls of `configure` - return this.extend() + const extension = this.extend() + + extension.options = mergeDeep(this.options, options) as Options + + return extension } extend(extendedConfig: Partial> = {}) { diff --git a/packages/core/src/Node.ts b/packages/core/src/Node.ts index 8caf936f..82236614 100644 --- a/packages/core/src/Node.ts +++ b/packages/core/src/Node.ts @@ -432,11 +432,13 @@ export class Node { } configure(options: Partial = {}) { - this.options = mergeDeep(this.options, options) as Options - // return a new instance so we can use the same extension // with different calls of `configure` - return this.extend() + const extension = this.extend() + + extension.options = mergeDeep(this.options, options) as Options + + return extension } extend(extendedConfig: Partial> = {}) { diff --git a/tests/cypress/integration/core/extensionOptions.spec.ts b/tests/cypress/integration/core/extensionOptions.spec.ts index ef8e4abd..ee5a52f9 100644 --- a/tests/cypress/integration/core/extensionOptions.spec.ts +++ b/tests/cypress/integration/core/extensionOptions.spec.ts @@ -127,11 +127,13 @@ describe('extension options', () => { .create({ defaultOptions: { foo: 1, + bar: 2, }, }) const extension1 = extension.configure({ foo: 2, + bar: 4, }) const extension2 = extension.configure({ @@ -140,10 +142,12 @@ describe('extension options', () => { expect(extension1.options).to.deep.eq({ foo: 2, + bar: 4, }) expect(extension2.options).to.deep.eq({ foo: 3, + bar: 2, }) }) })