Skip to content

Commit b020799

Browse files
author
tohosaku
committed
Fix for custom theme (has no css rules)
1 parent 237db7a commit b020799

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/core.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ export class JSONEditor {
4343
/* Attempt to locate a shadowRoot parent (i.e. in Web Components) */
4444
const shadowRoot = getShadowParent(this.element)
4545
addRules('default', rules, shadowRoot)
46-
addRules(themeName, themeClass.rules, shadowRoot)
46+
if (typeof themeClass.rules !== 'undefined') {
47+
addRules(themeName, themeClass.rules, shadowRoot)
48+
}
4749
}
4850

4951
/* Init icon class */

tests/unit/core.spec.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ describe('JSONEditor', function () {
7878
expect(editor.theme).toBeTruthy()
7979
})
8080

81+
it('can add custom theme (no custom css rules)', () => {
82+
class CustomTheme extends JSONEditor.AbstractTheme {}
83+
JSONEditor.defaults.themes.myCustom2 = CustomTheme
84+
editor = new JSONEditor(element, { schema: schema, theme: 'myCustom2' })
85+
expect(editor.theme).toBeTruthy()
86+
})
87+
8188
it('can add custom editor', () => {
8289
class CustomEditor extends JSONEditor.AbstractEditor {}
8390
JSONEditor.defaults.editors.custom = CustomEditor

0 commit comments

Comments
 (0)