Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
6c29b2da
Commit
6c29b2da
authored
Dec 24, 2021
by
Denys Mishunov
Committed by
Himanshu Kapoor
Dec 26, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix re-use of extensions between instances
Changelog: fixed
parent
69a452c8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
1 deletion
+18
-1
app/assets/javascripts/editor/source_editor_instance.js
app/assets/javascripts/editor/source_editor_instance.js
+7
-1
spec/frontend/editor/source_editor_instance_spec.js
spec/frontend/editor/source_editor_instance_spec.js
+11
-0
No files found.
app/assets/javascripts/editor/source_editor_instance.js
View file @
6c29b2da
...
...
@@ -50,6 +50,10 @@ const utils = {
}
return
extensionsStore
.
get
(
extensionName
);
},
hasFullApiRegistered
:
(
targetMethods
,
newMethods
)
=>
{
return
newMethods
.
find
((
fn
)
=>
!
targetMethods
.
includes
(
fn
))
===
undefined
;
},
};
/** Class representing a Source Editor Instance */
...
...
@@ -132,7 +136,9 @@ export default class EditorInstance {
const
existingExt
=
utils
.
getStoredExtension
(
extensionsStore
,
definition
.
extensionName
);
if
(
existingExt
)
{
if
(
isEqual
(
extension
.
setupOptions
,
existingExt
.
setupOptions
))
{
return
existingExt
;
if
(
utils
.
hasFullApiRegistered
(
this
.
extensionsAPI
,
Object
.
keys
(
existingExt
.
api
)))
{
return
existingExt
;
}
}
this
.
unuseExtension
(
extensionsStore
,
existingExt
);
}
...
...
spec/frontend/editor/source_editor_instance_spec.js
View file @
6c29b2da
...
...
@@ -277,6 +277,17 @@ describe('Source Editor Instance', () => {
expect
(
extensionStore
.
set
).
toHaveBeenCalledWith
(
'
SEClassExtension
'
,
extension1
);
});
it
(
'
correctly registers methods from the existing extension on an instance
'
,
()
=>
{
const
seInstance2
=
new
SourceEditorInstance
({},
extensionStore
);
seInstance
.
use
({
definition
:
SEClassExtension
});
const
val1
=
seInstance
.
classExtMethod
();
seInstance2
.
use
({
definition
:
SEClassExtension
});
expect
(
seInstance2
.
classExtMethod
).
toBeDefined
();
expect
(
seInstance2
.
classExtMethod
()).
toBe
(
val1
);
// from helpers.js we know classExtMethod()returns a string. Hence `toBe`
});
it
.
each
`
desc | currentSetupOptions | newSetupOptions | expectedCallTimes
${
'
updates
'
}
|
${
undefined
}
|
${
defSetupOptions
}
|
${
2
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment