From 4b42f70b4ef567fcffd2ef80daebd428d02a918a Mon Sep 17 00:00:00 2001 From: Hunter Perrin Date: Thu, 14 Dec 2017 12:32:43 -0800 Subject: [PATCH] Updated package versions. Bumped version. --- lib/QueryEditor.js | 361 +++++++++++++++----------------- lib/SelectorEditor.js | 463 ++++++++++++++++++++---------------------- lib/ValueEditor.js | 144 ++++++------- package-lock.json | 10 +- package.json | 3 +- 5 files changed, 456 insertions(+), 525 deletions(-) diff --git a/lib/QueryEditor.js b/lib/QueryEditor.js index 56964cb..a8312eb 100644 --- a/lib/QueryEditor.js +++ b/lib/QueryEditor.js @@ -262,16 +262,16 @@ h: function hydrate() { encapsulateStyles(div); - div.className = "query-editor"; button.className = state.classButton; addListener(button, "click", click_handler); div_1.className = "options-editor"; - div_2.className = "selector-editor"; button_1.className = state.classAddButton; addListener(button_1, "click", click_handler_1); + div_2.className = "selector-editor"; + addListener(input, "change", input_change_handler); input.className = state.classCheckbox; input.type = "checkbox"; - addListener(input, "change", input_change_handler); + div.className = "query-editor"; }, m: function mount(target, anchor) { @@ -383,12 +383,11 @@ each_1_blocks.length = selectors.length; } + input.checked = state.showQuery; if (changed.classCheckbox) { input.className = state.classCheckbox; } - input.checked = state.showQuery; - if (state.showQuery) { if (if_block_1) { if_block_1.p(changed, state); @@ -452,42 +451,43 @@ } // (12:10) {{#each remainingOptions as option}} - function create_each_block(state, remainingOptions_1, option, option_index, component) { - var option_1, - option_1_value_value, - text_value = option, - text; + function create_each_block(state, remainingOptions_1, option_1, option_index, component) { + var option, + text_value = option_1, + text, + option_value_value; return { c: function create() { - option_1 = createElement("option"); + option = createElement("option"); text = createText(text_value); this.h(); }, h: function hydrate() { - option_1.__value = option_1_value_value = option; - option_1.value = option_1.__value; + option.__value = option_value_value = option_1; + option.value = option.__value; }, m: function mount(target, anchor) { - insertNode(option_1, target, anchor); - appendNode(text, option_1); + insertNode(option, target, anchor); + appendNode(text, option); }, - p: function update(changed, state, remainingOptions_1, option, option_index) { - if (changed.remainingOptions && option_1_value_value !== (option_1_value_value = option)) { - option_1.__value = option_1_value_value; + p: function update(changed, state, remainingOptions_1, option_1, option_index) { + if (changed.remainingOptions && text_value !== (text_value = option_1)) { + text.data = text_value; } - option_1.value = option_1.__value; - if (changed.remainingOptions && text_value !== (text_value = option)) { - text.data = text_value; + if (changed.remainingOptions && option_value_value !== (option_value_value = option_1)) { + option.__value = option_value_value; } + + option.value = option.__value; }, u: function unmount() { - detachNode(option_1); + detachNode(option); }, d: noop @@ -500,6 +500,7 @@ text, select, option, + text_1, select_updating = false; var remainingOptions_1 = state.remainingOptions; @@ -512,8 +513,7 @@ function select_change_handler() { select_updating = true; - var selectedOption = select.querySelector(':checked') || select.options[0]; - component.set({ __newOption: selectedOption && selectedOption.__value }); + component.set({ __newOption: selectValue(select) }); select_updating = false; } @@ -527,7 +527,7 @@ text = createText("Add Option:\n "); select = createElement("select"); option = createElement("option"); - option.textContent = "- Select an Option -"; + text_1 = createText("- Select an Option -"); for (var i = 0; i < each_blocks.length; i += 1) { each_blocks[i].c(); @@ -539,11 +539,9 @@ option.selected = true; option.__value = ''; option.value = option.__value; - select.className = state.classSelect; - - if (!('__newOption' in state)) component._root._beforecreate.push(select_change_handler); - addListener(select, "change", select_change_handler); + if (!('__newOption' in state)) component.root._beforecreate.push(select_change_handler); + select.className = state.classSelect; addListener(select, "change", change_handler); }, @@ -552,20 +550,13 @@ appendNode(text, div); appendNode(select, div); appendNode(option, select); + appendNode(text_1, option); for (var i = 0; i < each_blocks.length; i += 1) { each_blocks[i].m(select, null); } - var value = state.__newOption; - for (var i = 0; i < select.options.length; i += 1) { - var option_2 = select.options[i]; - - if (option_2.__value === value) { - option_2.selected = true; - break; - } - } + selectOption(select, state.__newOption); }, p: function update(changed, state) { @@ -589,21 +580,10 @@ each_blocks.length = remainingOptions_1.length; } + if (!select_updating) selectOption(select, state.__newOption); if (changed.classSelect) { select.className = state.classSelect; } - - if (!select_updating) { - var value = state.__newOption; - for (var i = 0; i < select.options.length; i += 1) { - var option_2 = select.options[i]; - - if (option_2.__value === value) { - option_2.selected = true; - break; - } - } - } }, u: function unmount() { @@ -624,10 +604,10 @@ } // (21:4) {{#each optionsKeysTypes as option}} - function create_each_block_1(state, optionsKeysTypes_1, option_1, option_index, component) { + function create_each_block_1(state, optionsKeysTypes_1, option, option_index, component) { var div, div_1, - text_value = option_1.key, + text_value = option.key, text, text_1, text_2, @@ -636,8 +616,8 @@ div_3, button; - var current_block_type = select_block_type(state, optionsKeysTypes_1, option_1, option_index); - var if_block = current_block_type(state, optionsKeysTypes_1, option_1, option_index, component); + var current_block_type = select_block_type(state, optionsKeysTypes_1, option, option_index); + var if_block = current_block_type(state, optionsKeysTypes_1, option, option_index, component); return { c: function create() { @@ -656,10 +636,8 @@ }, h: function hydrate() { - div.className = "option"; div_1.className = "name"; div_2.className = "value"; - div_3.className = "remove"; button.className = state.classRemoveButton; addListener(button, "click", click_handler); @@ -668,6 +646,9 @@ optionsKeysTypes_1: optionsKeysTypes_1, option_index: option_index }; + + div_3.className = "remove"; + div.className = "option"; }, m: function mount(target, anchor) { @@ -683,17 +664,17 @@ appendNode(button, div_3); }, - p: function update(changed, state, optionsKeysTypes_1, option_1, option_index) { - if (changed.optionsKeysTypes && text_value !== (text_value = option_1.key)) { + p: function update(changed, state, optionsKeysTypes_1, option, option_index) { + if (changed.optionsKeysTypes && text_value !== (text_value = option.key)) { text.data = text_value; } - if (current_block_type === (current_block_type = select_block_type(state, optionsKeysTypes_1, option_1, option_index)) && if_block) { - if_block.p(changed, state, optionsKeysTypes_1, option_1, option_index); + if (current_block_type === (current_block_type = select_block_type(state, optionsKeysTypes_1, option, option_index)) && if_block) { + if_block.p(changed, state, optionsKeysTypes_1, option, option_index); } else { if_block.u(); if_block.d(); - if_block = current_block_type(state, optionsKeysTypes_1, option_1, option_index, component); + if_block = current_block_type(state, optionsKeysTypes_1, option, option_index, component); if_block.c(); if_block.m(div_2, null); } @@ -719,42 +700,43 @@ } // (29:14) {{#each supportedClasses as curClass}} - function create_each_block_2(state, optionsKeysTypes_1, option_1, option_index, supportedClasses, curClass, curClass_index, component) { - var option_2, - option_2_value_value, + function create_each_block_2(state, optionsKeysTypes_1, option, option_index, supportedClasses, curClass, curClass_index, component) { + var option_1, text_value = curClass.class, - text; + text, + option_1_value_value; return { c: function create() { - option_2 = createElement("option"); + option_1 = createElement("option"); text = createText(text_value); this.h(); }, h: function hydrate() { - option_2.__value = option_2_value_value = curClass.class; - option_2.value = option_2.__value; + option_1.__value = option_1_value_value = curClass.class; + option_1.value = option_1.__value; }, m: function mount(target, anchor) { - insertNode(option_2, target, anchor); - appendNode(text, option_2); + insertNode(option_1, target, anchor); + appendNode(text, option_1); }, - p: function update(changed, state, optionsKeysTypes_1, option_1, option_index, supportedClasses, curClass, curClass_index) { - if (changed.supportedClasses && option_2_value_value !== (option_2_value_value = curClass.class)) { - option_2.__value = option_2_value_value; - } - - option_2.value = option_2.__value; + p: function update(changed, state, optionsKeysTypes_1, option, option_index, supportedClasses, curClass, curClass_index) { if (changed.supportedClasses && text_value !== (text_value = curClass.class)) { text.data = text_value; } + + if (changed.supportedClasses && option_1_value_value !== (option_1_value_value = curClass.class)) { + option_1.__value = option_1_value_value; + } + + option_1.value = option_1.__value; }, u: function unmount() { - detachNode(option_2); + detachNode(option_1); }, d: noop @@ -762,42 +744,43 @@ } // (45:14) {{#each option.type as enumVal}} - function create_each_block_3(state, optionsKeysTypes_1, option_1, option_index, type, enumVal, enumVal_index, component) { - var option_2, - option_2_value_value, + function create_each_block_3(state, optionsKeysTypes_1, option, option_index, type, enumVal, enumVal_index, component) { + var option_1, text_value = enumVal, - text; + text, + option_1_value_value; return { c: function create() { - option_2 = createElement("option"); + option_1 = createElement("option"); text = createText(text_value); this.h(); }, h: function hydrate() { - option_2.__value = option_2_value_value = enumVal; - option_2.value = option_2.__value; + option_1.__value = option_1_value_value = enumVal; + option_1.value = option_1.__value; }, m: function mount(target, anchor) { - insertNode(option_2, target, anchor); - appendNode(text, option_2); + insertNode(option_1, target, anchor); + appendNode(text, option_1); }, - p: function update(changed, state, optionsKeysTypes_1, option_1, option_index, type, enumVal, enumVal_index) { - if (changed.optionsKeysTypes && option_2_value_value !== (option_2_value_value = enumVal)) { - option_2.__value = option_2_value_value; - } - - option_2.value = option_2.__value; + p: function update(changed, state, optionsKeysTypes_1, option, option_index, type, enumVal, enumVal_index) { if (changed.optionsKeysTypes && text_value !== (text_value = enumVal)) { text.data = text_value; } + + if (changed.optionsKeysTypes && option_1_value_value !== (option_1_value_value = enumVal)) { + option_1.__value = option_1_value_value; + } + + option_1.value = option_1.__value; }, u: function unmount() { - detachNode(option_2); + detachNode(option_1); }, d: noop @@ -805,7 +788,7 @@ } // (27:10) {{#if option.type === "class"}} - function create_if_block_1(state, optionsKeysTypes_1, option_1, option_index, component) { + function create_if_block_1(state, optionsKeysTypes_1, option, option_index, component) { var select, select_updating = false; @@ -814,15 +797,14 @@ var each_blocks = []; for (var i = 0; i < supportedClasses.length; i += 1) { - each_blocks[i] = create_each_block_2(state, optionsKeysTypes_1, option_1, option_index, supportedClasses, supportedClasses[i], i, component); + each_blocks[i] = create_each_block_2(state, optionsKeysTypes_1, option, option_index, supportedClasses, supportedClasses[i], i, component); } function select_change_handler() { - select_updating = true; - var selectedOption = select.querySelector(':checked') || select.options[0]; var state = component.get(); - state.options[option_1.key] = selectedOption && selectedOption.__value; - component.set({ options: state.options, optionsKeysTypes: state.optionsKeysTypes }); + select_updating = true; + state.options[option.key] = selectValue(select); + component.set({ options: state.options }); select_updating = false; } @@ -837,11 +819,9 @@ }, h: function hydrate() { - select.className = state.classSelect; - - if (!('options' in state)) component._root._beforecreate.push(select_change_handler); - addListener(select, "change", select_change_handler); + if (!('options' in state)) component.root._beforecreate.push(select_change_handler); + select.className = state.classSelect; select._svelte = { optionsKeysTypes_1: optionsKeysTypes_1, @@ -856,26 +836,18 @@ each_blocks[i].m(select, null); } - var value = state.options[option_1.key]; - for (var i = 0; i < select.options.length; i += 1) { - var option_2 = select.options[i]; - - if (option_2.__value === value) { - option_2.selected = true; - break; - } - } + selectOption(select, state.options[option.key]); }, - p: function update(changed, state, optionsKeysTypes_1, option_1, option_index) { + p: function update(changed, state, optionsKeysTypes_1, option, option_index) { var supportedClasses = state.supportedClasses; if (changed.supportedClasses) { for (var i = 0; i < supportedClasses.length; i += 1) { if (each_blocks[i]) { - each_blocks[i].p(changed, state, optionsKeysTypes_1, option_1, option_index, supportedClasses, supportedClasses[i], i); + each_blocks[i].p(changed, state, optionsKeysTypes_1, option, option_index, supportedClasses, supportedClasses[i], i); } else { - each_blocks[i] = create_each_block_2(state, optionsKeysTypes_1, option_1, option_index, supportedClasses, supportedClasses[i], i, component); + each_blocks[i] = create_each_block_2(state, optionsKeysTypes_1, option, option_index, supportedClasses, supportedClasses[i], i, component); each_blocks[i].c(); each_blocks[i].m(select, null); } @@ -888,22 +860,11 @@ each_blocks.length = supportedClasses.length; } + if (!select_updating) selectOption(select, state.options[option.key]); if (changed.classSelect) { select.className = state.classSelect; } - if (!select_updating) { - var value = state.options[option_1.key]; - for (var i = 0; i < select.options.length; i += 1) { - var option_2 = select.options[i]; - - if (option_2.__value === value) { - option_2.selected = true; - break; - } - } - } - select._svelte.optionsKeysTypes_1 = optionsKeysTypes_1; select._svelte.option_index = option_index; }, @@ -925,28 +886,28 @@ } // (35:99) - function create_if_block_2(state, optionsKeysTypes_1, option_1, option_index, component) { + function create_if_block_2(state, optionsKeysTypes_1, option, option_index, component) { var valueeditor_updating = {}; var valueeditor_initial_data = { - valueTypeInitial: option_1.type, - allowedTypes: [option_1.type], + valueTypeInitial: option.type, + allowedTypes: [option.type], classCheckbox: state.classCheckbox, classInput: state.classInput, classSelect: state.classSelect }; - if (option_1.key in state.options) { - valueeditor_initial_data.value = state.options[option_1.key]; + if (option.key in state.options) { + valueeditor_initial_data.value = state.options[option.key]; valueeditor_updating.value = true; } var valueeditor = new _ValueEditor2.default({ - _root: component._root, + root: component.root, data: valueeditor_initial_data, _bind: function _bind(changed, childState) { var state = component.get(), newState = {}; if (!valueeditor_updating.value && changed.value) { - state.options[option_1.key] = childState.value; + state.options[option.key] = childState.value; newState.options = state.options; newState.optionsKeysTypes = state.optionsKeysTypes; } @@ -956,13 +917,13 @@ } }); - component._root._beforecreate.push(function () { + component.root._beforecreate.push(function () { var state = component.get(), childState = valueeditor.get(), newState = {}; if (!childState) return; if (!valueeditor_updating.value) { - state.options[option_1.key] = childState.value; + state.options[option.key] = childState.value; newState.options = state.options; newState.optionsKeysTypes = state.optionsKeysTypes; } @@ -986,15 +947,15 @@ valueeditor._mount(target, anchor); }, - p: function update(changed, state, optionsKeysTypes_1, option_1, option_index) { + p: function update(changed, state, optionsKeysTypes_1, option, option_index) { var valueeditor_changes = {}; - if (changed.optionsKeysTypes) valueeditor_changes.valueTypeInitial = option_1.type; - if (changed.optionsKeysTypes) valueeditor_changes.allowedTypes = [option_1.type]; + if (changed.optionsKeysTypes) valueeditor_changes.valueTypeInitial = option.type; + if (changed.optionsKeysTypes) valueeditor_changes.allowedTypes = [option.type]; if (changed.classCheckbox) valueeditor_changes.classCheckbox = state.classCheckbox; if (changed.classInput) valueeditor_changes.classInput = state.classInput; if (changed.classSelect) valueeditor_changes.classSelect = state.classSelect; if (!valueeditor_updating.value && changed.options || changed.optionsKeysTypes) { - valueeditor_changes.value = state.options[option_1.key]; + valueeditor_changes.value = state.options[option.key]; valueeditor_updating.value = true; } valueeditor._set(valueeditor_changes); @@ -1016,24 +977,23 @@ } // (43:10) {{else}} - function create_if_block_3(state, optionsKeysTypes_1, option_1, option_index, component) { + function create_if_block_3(state, optionsKeysTypes_1, option, option_index, component) { var select, select_updating = false; - var type = option_1.type; + var type = option.type; var each_blocks = []; for (var i = 0; i < type.length; i += 1) { - each_blocks[i] = create_each_block_3(state, optionsKeysTypes_1, option_1, option_index, type, type[i], i, component); + each_blocks[i] = create_each_block_3(state, optionsKeysTypes_1, option, option_index, type, type[i], i, component); } function select_change_handler() { - select_updating = true; - var selectedOption = select.querySelector(':checked') || select.options[0]; var state = component.get(); - state.options[option_1.key] = selectedOption && selectedOption.__value; - component.set({ options: state.options, optionsKeysTypes: state.optionsKeysTypes }); + select_updating = true; + state.options[option.key] = selectValue(select); + component.set({ options: state.options }); select_updating = false; } @@ -1048,11 +1008,9 @@ }, h: function hydrate() { - select.className = state.classSelect; - - if (!('options' in state)) component._root._beforecreate.push(select_change_handler); - addListener(select, "change", select_change_handler); + if (!('options' in state)) component.root._beforecreate.push(select_change_handler); + select.className = state.classSelect; select._svelte = { optionsKeysTypes_1: optionsKeysTypes_1, @@ -1067,26 +1025,18 @@ each_blocks[i].m(select, null); } - var value = state.options[option_1.key]; - for (var i = 0; i < select.options.length; i += 1) { - var option_2 = select.options[i]; - - if (option_2.__value === value) { - option_2.selected = true; - break; - } - } + selectOption(select, state.options[option.key]); }, - p: function update(changed, state, optionsKeysTypes_1, option_1, option_index) { - var type = option_1.type; + p: function update(changed, state, optionsKeysTypes_1, option, option_index) { + var type = option.type; if (changed.optionsKeysTypes) { for (var i = 0; i < type.length; i += 1) { if (each_blocks[i]) { - each_blocks[i].p(changed, state, optionsKeysTypes_1, option_1, option_index, type, type[i], i); + each_blocks[i].p(changed, state, optionsKeysTypes_1, option, option_index, type, type[i], i); } else { - each_blocks[i] = create_each_block_3(state, optionsKeysTypes_1, option_1, option_index, type, type[i], i, component); + each_blocks[i] = create_each_block_3(state, optionsKeysTypes_1, option, option_index, type, type[i], i, component); each_blocks[i].c(); each_blocks[i].m(select, null); } @@ -1099,22 +1049,11 @@ each_blocks.length = type.length; } + if (!select_updating) selectOption(select, state.options[option.key]); if (changed.classSelect) { select.className = state.classSelect; } - if (!select_updating) { - var value = state.options[option_1.key]; - for (var i = 0; i < select.options.length; i += 1) { - var option_2 = select.options[i]; - - if (option_2.__value === value) { - option_2.selected = true; - break; - } - } - } - select._svelte.optionsKeysTypes_1 = optionsKeysTypes_1; select._svelte.option_index = option_index; }, @@ -1151,7 +1090,7 @@ selectoreditor_updating.selector = true; } var selectoreditor = new _SelectorEditor2.default({ - _root: component._root, + root: component.root, data: selectoreditor_initial_data, _bind: function _bind(changed, childState) { var state = component.get(), @@ -1169,7 +1108,7 @@ } }); - component._root._beforecreate.push(function () { + component.root._beforecreate.push(function () { var state = component.get(), childState = selectoreditor.get(), newState = {}; @@ -1252,8 +1191,8 @@ }, h: function hydrate() { - div.className = "query-result"; pre.className = "query"; + div.className = "query-result"; }, m: function mount(target, anchor) { @@ -1326,13 +1265,13 @@ }, h: function hydrate() { - div.className = "help-dialog-container"; div_1.className = "help-dialog-overlay"; addListener(div_1, "click", click_handler_1); - div_2.className = "help-dialog"; - div_9.className = "actions"; button.className = state.classButton; addListener(button, "click", click_handler_2); + div_9.className = "actions"; + div_2.className = "help-dialog"; + div.className = "help-dialog-container"; }, m: function mount(target, anchor) { @@ -1375,9 +1314,9 @@ }; } - function select_block_type(state, optionsKeysTypes_1, option_1, option_index) { - if (option_1.type === "class") return create_if_block_1; - if (option_1.type === "int" || option_1.type === "boolean" || option_1.type === "string") return create_if_block_2; + function select_block_type(state, optionsKeysTypes_1, option, option_index) { + if (option.type === "class") return create_if_block_1; + if (option.type === "int" || option.type === "boolean" || option.type === "string") return create_if_block_2; return create_if_block_3; } @@ -1385,8 +1324,8 @@ var component = this._svelte.component; var optionsKeysTypes_1 = this._svelte.optionsKeysTypes_1, option_index = this._svelte.option_index, - option_1 = optionsKeysTypes_1[option_index]; - component.removeOption(option_1.key); + option = optionsKeysTypes_1[option_index]; + component.removeOption(option.key); } function QueryEditor(options) { @@ -1396,7 +1335,7 @@ if (!document.getElementById("svelte-331703558-style")) add_css(); - if (!options._root) { + if (!options.root) { this._oncreate = []; this._beforecreate = []; this._aftercreate = []; @@ -1480,6 +1419,22 @@ function noop() {} + function selectValue(select) { + var selectedOption = select.querySelector(':checked') || select.options[0]; + return selectedOption && selectedOption.__value; + } + + function selectOption(select, value) { + for (var i = 0; i < select.options.length; i += 1) { + var option = select.options[i]; + + if (option.__value === value) { + option.selected = true; + return; + } + } + } + function assign(target) { var k, source, @@ -1496,12 +1451,13 @@ } function init(component, options) { - component.options = options; - component._observers = { pre: blankObject(), post: blankObject() }; component._handlers = blankObject(); - component._root = options._root || component; component._bind = options._bind; + + component.options = options; + component.root = options.root || component; + component.store = component.root.options.store; } function callAll(fns) { @@ -1568,12 +1524,12 @@ function set(newState) { this._set(assign({}, newState)); - if (this._root._lock) return; - this._root._lock = true; - callAll(this._root._beforecreate); - callAll(this._root._oncreate); - callAll(this._root._aftercreate); - this._root._lock = false; + if (this.root._lock) return; + this.root._lock = true; + callAll(this.root._beforecreate); + callAll(this.root._oncreate); + callAll(this.root._aftercreate); + this.root._lock = false; } function _set(newState) { @@ -1589,9 +1545,12 @@ this._state = assign({}, oldState, newState); this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); - dispatchObservers(this, this._observers.pre, changed, this._state, oldState); - this._fragment.p(changed, this._state); - dispatchObservers(this, this._observers.post, changed, this._state, oldState); + + if (this._fragment) { + dispatchObservers(this, this._observers.pre, changed, this._state, oldState); + this._fragment.p(changed, this._state); + dispatchObservers(this, this._observers.post, changed, this._state, oldState); + } } function _mount(target, anchor) { @@ -1599,7 +1558,7 @@ } function _unmount() { - this._fragment.u(); + if (this._fragment) this._fragment.u(); } function differs(a, b) { diff --git a/lib/SelectorEditor.js b/lib/SelectorEditor.js index 1129eb0..610acfb 100644 --- a/lib/SelectorEditor.js +++ b/lib/SelectorEditor.js @@ -347,9 +347,13 @@ div_3, select, option, + text_3, option_1, + text_4, option_2, + text_5, option_3, + text_6, select_updating = false, text_9, text_10; @@ -357,10 +361,9 @@ var if_block = state.remainingClauses.length && create_if_block(state, component); function select_change_handler() { - select_updating = true; - var selectedOption = select.querySelector(':checked') || select.options[0]; var state = component.get(); - state.selector.type = selectedOption && selectedOption.__value; + select_updating = true; + state.selector.type = selectValue(select); component.set({ selector: state.selector }); select_updating = false; } @@ -385,13 +388,13 @@ div_3 = createElement("div"); select = createElement("select"); option = createElement("option"); - option.textContent = "& (All clauses in the selector must be true.)"; + text_3 = createText("& (All clauses in the selector must be true.)"); option_1 = createElement("option"); - option_1.textContent = "| (At least one clause in the selector must be true.)"; + text_4 = createText("| (At least one clause in the selector must be true.)"); option_2 = createElement("option"); - option_2.textContent = "!& (All clauses in the selector must be false.)"; + text_5 = createText("!& (All clauses in the selector must be false.)"); option_3 = createElement("option"); - option_3.textContent = "!| (At least one clause in the selector must be false.)"; + text_6 = createText("!| (At least one clause in the selector must be false.)"); text_9 = createText("\n "); for (var i = 0; i < each_blocks.length; i += 1) { @@ -404,10 +407,7 @@ h: function hydrate() { encapsulateStyles(div); - div.className = "selector"; - div_1.className = "clause"; div_2.className = "name"; - div_3.className = "value"; option.__value = "&"; option.value = option.__value; option_1.__value = "|"; @@ -416,11 +416,12 @@ option_2.value = option_2.__value; option_3.__value = "!|"; option_3.value = option_3.__value; - select.className = state.classSelect; - - if (!('selector' in state)) component._root._beforecreate.push(select_change_handler); - addListener(select, "change", select_change_handler); + if (!('selector' in state)) component.root._beforecreate.push(select_change_handler); + select.className = state.classSelect; + div_3.className = "value"; + div_1.className = "clause"; + div.className = "selector"; }, m: function mount(target, anchor) { @@ -433,19 +434,15 @@ appendNode(div_3, div_1); appendNode(select, div_3); appendNode(option, select); + appendNode(text_3, option); appendNode(option_1, select); + appendNode(text_4, option_1); appendNode(option_2, select); + appendNode(text_5, option_2); appendNode(option_3, select); + appendNode(text_6, option_3); - var value = state.selector.type; - for (var i = 0; i < select.options.length; i += 1) { - var option_4 = select.options[i]; - - if (option_4.__value === value) { - option_4.selected = true; - break; - } - } + selectOption(select, state.selector.type); appendNode(text_9, div); @@ -471,22 +468,11 @@ if_block = null; } + if (!select_updating) selectOption(select, state.selector.type); if (changed.classSelect) { select.className = state.classSelect; } - if (!select_updating) { - var value = state.selector.type; - for (var i = 0; i < select.options.length; i += 1) { - var option_4 = select.options[i]; - - if (option_4.__value === value) { - option_4.selected = true; - break; - } - } - } - var clausesKeysTypes_1 = state.clausesKeysTypes; if (changed.clausesKeysTypes || changed.selector || changed.classCheckbox || changed.classInput || changed.classSelect || changed.classAddButton || changed.classRemoveButton || changed.isCompoundVectorClauseKeys || changed.isCompoundScalarClauseKeys) { @@ -529,9 +515,9 @@ // (9:8) {{#each remainingClauses as clause}} function create_each_block(state, remainingClauses_1, clause, clause_index, component) { var option, - option_value_value, text_value = clause, - text; + text, + option_value_value; return { c: function create() { @@ -551,14 +537,15 @@ }, p: function update(changed, state, remainingClauses_1, clause, clause_index) { + if (changed.remainingClauses && text_value !== (text_value = clause)) { + text.data = text_value; + } + if (changed.remainingClauses && option_value_value !== (option_value_value = clause)) { option.__value = option_value_value; } option.value = option.__value; - if (changed.remainingClauses && text_value !== (text_value = clause)) { - text.data = text_value; - } }, u: function unmount() { @@ -575,6 +562,7 @@ text, select, option, + text_1, select_updating = false, text_2, button, @@ -591,8 +579,7 @@ function select_change_handler() { select_updating = true; - var selectedOption = select.querySelector(':checked') || select.options[0]; - component.set({ __newClause: selectedOption && selectedOption.__value }); + component.set({ __newClause: selectValue(select) }); select_updating = false; } @@ -614,7 +601,7 @@ text = createText("Add Clause:\n "); select = createElement("select"); option = createElement("option"); - option.textContent = "- Select a Clause -"; + text_1 = createText("- Select a Clause -"); for (var i = 0; i < each_blocks.length; i += 1) { each_blocks[i].c(); @@ -633,11 +620,9 @@ option.selected = true; option.__value = ''; option.value = option.__value; - select.className = state.classSelect; - - if (!('__newClause' in state)) component._root._beforecreate.push(select_change_handler); - addListener(select, "change", select_change_handler); + if (!('__newClause' in state)) component.root._beforecreate.push(select_change_handler); + select.className = state.classSelect; addListener(select, "change", change_handler); button.className = state.classAddButton; addListener(button, "click", click_handler); @@ -650,20 +635,13 @@ appendNode(text, div); appendNode(select, div); appendNode(option, select); + appendNode(text_1, option); for (var i = 0; i < each_blocks.length; i += 1) { each_blocks[i].m(select, null); } - var value = state.__newClause; - for (var i = 0; i < select.options.length; i += 1) { - var option_1 = select.options[i]; - - if (option_1.__value === value) { - option_1.selected = true; - break; - } - } + selectOption(select, state.__newClause); appendNode(text_2, div); appendNode(button, div); @@ -692,22 +670,11 @@ each_blocks.length = remainingClauses_1.length; } + if (!select_updating) selectOption(select, state.__newClause); if (changed.classSelect) { select.className = state.classSelect; } - if (!select_updating) { - var value = state.__newClause; - for (var i = 0; i < select.options.length; i += 1) { - var option_1 = select.options[i]; - - if (option_1.__value === value) { - option_1.selected = true; - break; - } - } - } - if (changed.classAddButton) { button.className = state.classAddButton; } @@ -737,20 +704,20 @@ } // (41:2) {{#each clausesKeysTypes as clause}} - function create_each_block_1(state, clausesKeysTypes_1, clause_1, clause_index, component) { + function create_each_block_1(state, clausesKeysTypes_1, clause, clause_index, component) { var div, div_1, - text_value = clause_1.key, + text_value = clause.key, text, text_1, text_2, div_2, text_4; - var current_block_type = select_block_type_2(state, clausesKeysTypes_1, clause_1, clause_index); - var if_block = current_block_type(state, clausesKeysTypes_1, clause_1, clause_index, component); + var current_block_type = select_block_type_2(state, clausesKeysTypes_1, clause, clause_index); + var if_block = current_block_type(state, clausesKeysTypes_1, clause, clause_index, component); - var if_block_1 = clause_1.type !== "selector" && create_if_block_8(state, clausesKeysTypes_1, clause_1, clause_index, component); + var if_block_1 = clause.type !== "selector" && create_if_block_8(state, clausesKeysTypes_1, clause, clause_index, component); return { c: function create() { @@ -767,9 +734,9 @@ }, h: function hydrate() { - div.className = "clause"; div_1.className = "name"; div_2.className = "value"; + div.className = "clause"; }, m: function mount(target, anchor) { @@ -784,26 +751,26 @@ if (if_block_1) if_block_1.m(div, null); }, - p: function update(changed, state, clausesKeysTypes_1, clause_1, clause_index) { - if (changed.clausesKeysTypes && text_value !== (text_value = clause_1.key)) { + p: function update(changed, state, clausesKeysTypes_1, clause, clause_index) { + if (changed.clausesKeysTypes && text_value !== (text_value = clause.key)) { text.data = text_value; } - if (current_block_type === (current_block_type = select_block_type_2(state, clausesKeysTypes_1, clause_1, clause_index)) && if_block) { - if_block.p(changed, state, clausesKeysTypes_1, clause_1, clause_index); + if (current_block_type === (current_block_type = select_block_type_2(state, clausesKeysTypes_1, clause, clause_index)) && if_block) { + if_block.p(changed, state, clausesKeysTypes_1, clause, clause_index); } else { if_block.u(); if_block.d(); - if_block = current_block_type(state, clausesKeysTypes_1, clause_1, clause_index, component); + if_block = current_block_type(state, clausesKeysTypes_1, clause, clause_index, component); if_block.c(); if_block.m(div_2, null); } - if (clause_1.type !== "selector") { + if (clause.type !== "selector") { if (if_block_1) { - if_block_1.p(changed, state, clausesKeysTypes_1, clause_1, clause_index); + if_block_1.p(changed, state, clausesKeysTypes_1, clause, clause_index); } else { - if_block_1 = create_if_block_8(state, clausesKeysTypes_1, clause_1, clause_index, component); + if_block_1 = create_if_block_8(state, clausesKeysTypes_1, clause, clause_index, component); if_block_1.c(); if_block_1.m(div, null); } @@ -828,7 +795,7 @@ } // (63:14) {{#each selector[clause.key] as clauseEntry, index}} - function create_each_block_2(state, clausesKeysTypes_1, clause_1, clause_index, each_value, clauseEntry, index, component) { + function create_each_block_2(state, clausesKeysTypes_1, clause, clause_index, each_value, clauseEntry, index, component) { var div, text, input, @@ -839,19 +806,17 @@ button; function input_input_handler() { - input_updating = true; - var list = input._svelte.each_value; - var index = input._svelte.index; + var context = input._svelte; var state = component.get(); - list[index][0] = input.value; - + input_updating = true; + context.each_value[context.index][0] = input.value; component.set({ selector: state.selector, clausesKeysTypes: state.clausesKeysTypes }); input_updating = false; } var valueeditor_initial_data = { - valueTypeInitial: clause_1.type.type, - allowedTypes: clause_1.type.allowedTypes, + valueTypeInitial: clause.type.type, + allowedTypes: clause.type.allowedTypes, classCheckbox: state.classCheckbox, classInput: state.classInput, classSelect: state.classSelect @@ -865,7 +830,7 @@ valueeditor_updating.wholeEntry = true; } var valueeditor = new _ValueEditor2.default({ - _root: component._root, + root: component.root, data: valueeditor_initial_data, _bind: function _bind(changed, childState) { var state = component.get(), @@ -893,7 +858,7 @@ } }); - component._root._beforecreate.push(function () { + component.root._beforecreate.push(function () { var state = component.get(), childState = valueeditor.get(), newState = {}; @@ -928,9 +893,8 @@ index = valueeditor_context.index, clauseEntry = each_value[index]; - component.makeDate(clause_1.key, index); + component.makeDate(clause.key, index); }); - valueeditor.on("makeNotDate", function (event) { var clausesKeysTypes_1 = valueeditor_context.clausesKeysTypes_1, clause_index = valueeditor_context.clause_index, @@ -939,14 +903,14 @@ index = valueeditor_context.index, clauseEntry = each_value[index]; - component.makeNotDate(clause_1.key, index); + component.makeNotDate(clause.key, index); }); var valueeditor_context = { - each_value: each_value, - index: index, clausesKeysTypes_1: clausesKeysTypes_1, - clause_index: clause_index + clause_index: clause_index, + each_value: each_value, + index: index }; return { @@ -963,11 +927,10 @@ }, h: function hydrate() { - div.className = "clause-entry"; + addListener(input, "input", input_input_handler); input.className = state.classInput; input.type = "text"; input.placeholder = "property name"; - addListener(input, "input", input_input_handler); input._svelte = { each_value: each_value, @@ -984,6 +947,8 @@ each_value: each_value, index: index }; + + div.className = "clause-entry"; }, m: function mount(target, anchor) { @@ -999,21 +964,18 @@ appendNode(button, div); }, - p: function update(changed, state, clausesKeysTypes_1, clause_1, clause_index, each_value, clauseEntry, index) { + p: function update(changed, state, clausesKeysTypes_1, clause, clause_index, each_value, clauseEntry, index) { + if (!input_updating) input.value = clauseEntry[0]; if (changed.classInput) { input.className = state.classInput; } - if (!input_updating) { - input.value = clauseEntry[0]; - } - input._svelte.each_value = each_value; input._svelte.index = index; var valueeditor_changes = {}; - if (changed.clausesKeysTypes) valueeditor_changes.valueTypeInitial = clause_1.type.type; - if (changed.clausesKeysTypes) valueeditor_changes.allowedTypes = clause_1.type.allowedTypes; + if (changed.clausesKeysTypes) valueeditor_changes.valueTypeInitial = clause.type.type; + if (changed.clausesKeysTypes) valueeditor_changes.allowedTypes = clause.type.allowedTypes; if (changed.classCheckbox) valueeditor_changes.classCheckbox = state.classCheckbox; if (changed.classInput) valueeditor_changes.classInput = state.classInput; if (changed.classSelect) valueeditor_changes.classSelect = state.classSelect; @@ -1028,10 +990,10 @@ valueeditor._set(valueeditor_changes); valueeditor_updating = {}; - valueeditor_context.each_value = each_value; - valueeditor_context.index = index; valueeditor_context.clausesKeysTypes_1 = clausesKeysTypes_1; valueeditor_context.clause_index = clause_index; + valueeditor_context.each_value = each_value; + valueeditor_context.index = index; if (changed.classRemoveButton) { button.className = state.classRemoveButton; @@ -1056,15 +1018,15 @@ } // (62:12) {{#if isCompoundVectorClauseKeys[clause.key]}} - function create_if_block_4(state, clausesKeysTypes_1, clause_1, clause_index, component) { + function create_if_block_4(state, clausesKeysTypes_1, clause, clause_index, component) { var each_anchor; - var each_value = state.selector[clause_1.key]; + var each_value = state.selector[clause.key]; var each_blocks = []; for (var i = 0; i < each_value.length; i += 1) { - each_blocks[i] = create_each_block_2(state, clausesKeysTypes_1, clause_1, clause_index, each_value, each_value[i], i, component); + each_blocks[i] = create_each_block_2(state, clausesKeysTypes_1, clause, clause_index, each_value, each_value[i], i, component); } return { @@ -1084,15 +1046,15 @@ insertNode(each_anchor, target, anchor); }, - p: function update(changed, state, clausesKeysTypes_1, clause_1, clause_index) { - var each_value = state.selector[clause_1.key]; + p: function update(changed, state, clausesKeysTypes_1, clause, clause_index) { + var each_value = state.selector[clause.key]; if (changed.classInput || changed.selector || changed.clausesKeysTypes || changed.classCheckbox || changed.classSelect || changed.classRemoveButton) { for (var i = 0; i < each_value.length; i += 1) { if (each_blocks[i]) { - each_blocks[i].p(changed, state, clausesKeysTypes_1, clause_1, clause_index, each_value, each_value[i], i); + each_blocks[i].p(changed, state, clausesKeysTypes_1, clause, clause_index, each_value, each_value[i], i); } else { - each_blocks[i] = create_each_block_2(state, clausesKeysTypes_1, clause_1, clause_index, each_value, each_value[i], i, component); + each_blocks[i] = create_each_block_2(state, clausesKeysTypes_1, clause, clause_index, each_value, each_value[i], i, component); each_blocks[i].c(); each_blocks[i].m(each_anchor.parentNode, each_anchor); } @@ -1121,7 +1083,7 @@ } // (79:12) {{else}} - function create_if_block_5(state, clausesKeysTypes_1, clause_1, clause_index, component) { + function create_if_block_5(state, clausesKeysTypes_1, clause, clause_index, component) { var div, input, input_updating = false, @@ -1129,42 +1091,42 @@ valueeditor_updating = {}; function input_input_handler() { - input_updating = true; var state = component.get(); - state.selector[clause_1.key][0] = input.value; - component.set({ selector: state.selector, clausesKeysTypes: state.clausesKeysTypes }); + input_updating = true; + state.selector[clause.key][0] = input.value; + component.set({ selector: state.selector }); input_updating = false; } var valueeditor_initial_data = { - valueTypeInitial: clause_1.type.type, - allowedTypes: clause_1.type.allowedTypes, + valueTypeInitial: clause.type.type, + allowedTypes: clause.type.allowedTypes, classCheckbox: state.classCheckbox, classInput: state.classInput, classSelect: state.classSelect }; - if (1 in state.selector[clause_1.key]) { - valueeditor_initial_data.value = state.selector[clause_1.key][1]; + if (1 in state.selector[clause.key]) { + valueeditor_initial_data.value = state.selector[clause.key][1]; valueeditor_updating.value = true; } - if (clause_1.key in state.selector) { - valueeditor_initial_data.wholeEntry = state.selector[clause_1.key]; + if (clause.key in state.selector) { + valueeditor_initial_data.wholeEntry = state.selector[clause.key]; valueeditor_updating.wholeEntry = true; } var valueeditor = new _ValueEditor2.default({ - _root: component._root, + root: component.root, data: valueeditor_initial_data, _bind: function _bind(changed, childState) { var state = component.get(), newState = {}; if (!valueeditor_updating.value && changed.value) { - state.selector[clause_1.key][1] = childState.value; + state.selector[clause.key][1] = childState.value; newState.selector = state.selector; newState.clausesKeysTypes = state.clausesKeysTypes; } if (!valueeditor_updating.wholeEntry && changed.wholeEntry) { - state.selector[clause_1.key] = childState.wholeEntry; + state.selector[clause.key] = childState.wholeEntry; newState.selector = state.selector; newState.clausesKeysTypes = state.clausesKeysTypes; } @@ -1174,19 +1136,19 @@ } }); - component._root._beforecreate.push(function () { + component.root._beforecreate.push(function () { var state = component.get(), childState = valueeditor.get(), newState = {}; if (!childState) return; if (!valueeditor_updating.value) { - state.selector[clause_1.key][1] = childState.value; + state.selector[clause.key][1] = childState.value; newState.selector = state.selector; newState.clausesKeysTypes = state.clausesKeysTypes; } if (!valueeditor_updating.wholeEntry) { - state.selector[clause_1.key] = childState.wholeEntry; + state.selector[clause.key] = childState.wholeEntry; newState.selector = state.selector; newState.clausesKeysTypes = state.clausesKeysTypes; } @@ -1200,21 +1162,20 @@ clause_index = valueeditor_context.clause_index, clause = clausesKeysTypes_1[clause_index]; - component.makeDate(clause_1.key, null); + component.makeDate(clause.key, null); }); - valueeditor.on("makeNotDate", function (event) { var clausesKeysTypes_1 = valueeditor_context.clausesKeysTypes_1, clause_index = valueeditor_context.clause_index, clause = clausesKeysTypes_1[clause_index]; - component.makeNotDate(clause_1.key, null); + component.makeNotDate(clause.key, null); }); var valueeditor_context = { - state: state, clausesKeysTypes_1: clausesKeysTypes_1, - clause_index: clause_index + clause_index: clause_index, + state: state }; return { @@ -1227,60 +1188,58 @@ }, h: function hydrate() { - div.className = "clause-entry"; + addListener(input, "input", input_input_handler); input.className = state.classInput; input.type = "text"; input.placeholder = "property name"; - addListener(input, "input", input_input_handler); input._svelte = { clausesKeysTypes_1: clausesKeysTypes_1, clause_index: clause_index }; + + div.className = "clause-entry"; }, m: function mount(target, anchor) { insertNode(div, target, anchor); appendNode(input, div); - input.value = state.selector[clause_1.key][0]; + input.value = state.selector[clause.key][0]; appendNode(text, div); valueeditor._mount(div, null); }, - p: function update(changed, state, clausesKeysTypes_1, clause_1, clause_index) { + p: function update(changed, state, clausesKeysTypes_1, clause, clause_index) { + if (!input_updating) input.value = state.selector[clause.key][0]; if (changed.classInput) { input.className = state.classInput; } - if (!input_updating) { - input.value = state.selector[clause_1.key][0]; - } - input._svelte.clausesKeysTypes_1 = clausesKeysTypes_1; input._svelte.clause_index = clause_index; var valueeditor_changes = {}; - if (changed.clausesKeysTypes) valueeditor_changes.valueTypeInitial = clause_1.type.type; - if (changed.clausesKeysTypes) valueeditor_changes.allowedTypes = clause_1.type.allowedTypes; + if (changed.clausesKeysTypes) valueeditor_changes.valueTypeInitial = clause.type.type; + if (changed.clausesKeysTypes) valueeditor_changes.allowedTypes = clause.type.allowedTypes; if (changed.classCheckbox) valueeditor_changes.classCheckbox = state.classCheckbox; if (changed.classInput) valueeditor_changes.classInput = state.classInput; if (changed.classSelect) valueeditor_changes.classSelect = state.classSelect; if (!valueeditor_updating.value && changed.selector || changed.clausesKeysTypes) { - valueeditor_changes.value = state.selector[clause_1.key][1]; + valueeditor_changes.value = state.selector[clause.key][1]; valueeditor_updating.value = true; } if (!valueeditor_updating.wholeEntry && changed.selector || changed.clausesKeysTypes) { - valueeditor_changes.wholeEntry = state.selector[clause_1.key]; + valueeditor_changes.wholeEntry = state.selector[clause.key]; valueeditor_updating.wholeEntry = true; } valueeditor._set(valueeditor_changes); valueeditor_updating = {}; - valueeditor_context.state = state; valueeditor_context.clausesKeysTypes_1 = clausesKeysTypes_1; valueeditor_context.clause_index = clause_index; + valueeditor_context.state = state; }, u: function unmount() { @@ -1295,25 +1254,25 @@ } // (96:14) {{#each selector[clause.key] as clauseEntry, index}} - function create_each_block_3(state, clausesKeysTypes_1, clause_1, clause_index, each_value, clauseEntry_1, index, component) { + function create_each_block_3(state, clausesKeysTypes_1, clause, clause_index, each_value, clauseEntry, index, component) { var div, valueeditor_updating = {}, text, button; var valueeditor_initial_data = { - valueTypeInitial: clause_1.type.type, - allowedTypes: clause_1.type.allowedTypes, + valueTypeInitial: clause.type.type, + allowedTypes: clause.type.allowedTypes, classCheckbox: state.classCheckbox, classInput: state.classInput, classSelect: state.classSelect }; if (index in each_value) { - valueeditor_initial_data.value = clauseEntry_1; + valueeditor_initial_data.value = clauseEntry; valueeditor_updating.value = true; } var valueeditor = new _ValueEditor2.default({ - _root: component._root, + root: component.root, data: valueeditor_initial_data, _bind: function _bind(changed, childState) { var state = component.get(), @@ -1332,7 +1291,7 @@ } }); - component._root._beforecreate.push(function () { + component.root._beforecreate.push(function () { var state = component.get(), childState = valueeditor.get(), newState = {}; @@ -1366,7 +1325,6 @@ }, h: function hydrate() { - div.className = "clause-entry"; button.className = state.classRemoveButton; addListener(button, "click", click_handler_2); @@ -1377,6 +1335,8 @@ each_value: each_value, index: index }; + + div.className = "clause-entry"; }, m: function mount(target, anchor) { @@ -1386,15 +1346,15 @@ appendNode(button, div); }, - p: function update(changed, state, clausesKeysTypes_1, clause_1, clause_index, each_value, clauseEntry_1, index) { + p: function update(changed, state, clausesKeysTypes_1, clause, clause_index, each_value, clauseEntry, index) { var valueeditor_changes = {}; - if (changed.clausesKeysTypes) valueeditor_changes.valueTypeInitial = clause_1.type.type; - if (changed.clausesKeysTypes) valueeditor_changes.allowedTypes = clause_1.type.allowedTypes; + if (changed.clausesKeysTypes) valueeditor_changes.valueTypeInitial = clause.type.type; + if (changed.clausesKeysTypes) valueeditor_changes.allowedTypes = clause.type.allowedTypes; if (changed.classCheckbox) valueeditor_changes.classCheckbox = state.classCheckbox; if (changed.classInput) valueeditor_changes.classInput = state.classInput; if (changed.classSelect) valueeditor_changes.classSelect = state.classSelect; if (!valueeditor_updating.value && changed.selector || changed.clausesKeysTypes) { - valueeditor_changes.value = clauseEntry_1; + valueeditor_changes.value = clauseEntry; valueeditor_updating.value = true; } valueeditor._set(valueeditor_changes); @@ -1425,11 +1385,11 @@ } // (61:10) {{#if clause.type.vector}} - function create_if_block_3(state, clausesKeysTypes_1, clause_1, clause_index, component) { + function create_if_block_3(state, clausesKeysTypes_1, clause, clause_index, component) { var if_block_anchor; - var current_block_type = select_block_type(state, clausesKeysTypes_1, clause_1, clause_index); - var if_block = current_block_type(state, clausesKeysTypes_1, clause_1, clause_index, component); + var current_block_type = select_block_type(state, clausesKeysTypes_1, clause, clause_index); + var if_block = current_block_type(state, clausesKeysTypes_1, clause, clause_index, component); return { c: function create() { @@ -1442,13 +1402,13 @@ insertNode(if_block_anchor, target, anchor); }, - p: function update(changed, state, clausesKeysTypes_1, clause_1, clause_index) { - if (current_block_type === (current_block_type = select_block_type(state, clausesKeysTypes_1, clause_1, clause_index)) && if_block) { - if_block.p(changed, state, clausesKeysTypes_1, clause_1, clause_index); + p: function update(changed, state, clausesKeysTypes_1, clause, clause_index) { + if (current_block_type === (current_block_type = select_block_type(state, clausesKeysTypes_1, clause, clause_index)) && if_block) { + if_block.p(changed, state, clausesKeysTypes_1, clause, clause_index); } else { if_block.u(); if_block.d(); - if_block = current_block_type(state, clausesKeysTypes_1, clause_1, clause_index, component); + if_block = current_block_type(state, clausesKeysTypes_1, clause, clause_index, component); if_block.c(); if_block.m(if_block_anchor.parentNode, if_block_anchor); } @@ -1466,15 +1426,15 @@ } // (95:12) {{#if isCompoundScalarClauseKeys[clause.key]}} - function create_if_block_6(state, clausesKeysTypes_1, clause_1, clause_index, component) { + function create_if_block_6(state, clausesKeysTypes_1, clause, clause_index, component) { var each_anchor; - var each_value = state.selector[clause_1.key]; + var each_value = state.selector[clause.key]; var each_blocks = []; for (var i = 0; i < each_value.length; i += 1) { - each_blocks[i] = create_each_block_3(state, clausesKeysTypes_1, clause_1, clause_index, each_value, each_value[i], i, component); + each_blocks[i] = create_each_block_3(state, clausesKeysTypes_1, clause, clause_index, each_value, each_value[i], i, component); } return { @@ -1494,15 +1454,15 @@ insertNode(each_anchor, target, anchor); }, - p: function update(changed, state, clausesKeysTypes_1, clause_1, clause_index) { - var each_value = state.selector[clause_1.key]; + p: function update(changed, state, clausesKeysTypes_1, clause, clause_index) { + var each_value = state.selector[clause.key]; if (changed.selector || changed.clausesKeysTypes || changed.classCheckbox || changed.classInput || changed.classSelect || changed.classRemoveButton) { for (var i = 0; i < each_value.length; i += 1) { if (each_blocks[i]) { - each_blocks[i].p(changed, state, clausesKeysTypes_1, clause_1, clause_index, each_value, each_value[i], i); + each_blocks[i].p(changed, state, clausesKeysTypes_1, clause, clause_index, each_value, each_value[i], i); } else { - each_blocks[i] = create_each_block_3(state, clausesKeysTypes_1, clause_1, clause_index, each_value, each_value[i], i, component); + each_blocks[i] = create_each_block_3(state, clausesKeysTypes_1, clause, clause_index, each_value, each_value[i], i, component); each_blocks[i].c(); each_blocks[i].m(each_anchor.parentNode, each_anchor); } @@ -1531,29 +1491,29 @@ } // (108:12) {{else}} - function create_if_block_7(state, clausesKeysTypes_1, clause_1, clause_index, component) { + function create_if_block_7(state, clausesKeysTypes_1, clause, clause_index, component) { var div, valueeditor_updating = {}; var valueeditor_initial_data = { - valueTypeInitial: clause_1.type.type, - allowedTypes: clause_1.type.allowedTypes, + valueTypeInitial: clause.type.type, + allowedTypes: clause.type.allowedTypes, classCheckbox: state.classCheckbox, classInput: state.classInput, classSelect: state.classSelect }; - if (clause_1.key in state.selector) { - valueeditor_initial_data.value = state.selector[clause_1.key]; + if (clause.key in state.selector) { + valueeditor_initial_data.value = state.selector[clause.key]; valueeditor_updating.value = true; } var valueeditor = new _ValueEditor2.default({ - _root: component._root, + root: component.root, data: valueeditor_initial_data, _bind: function _bind(changed, childState) { var state = component.get(), newState = {}; if (!valueeditor_updating.value && changed.value) { - state.selector[clause_1.key] = childState.value; + state.selector[clause.key] = childState.value; newState.selector = state.selector; newState.clausesKeysTypes = state.clausesKeysTypes; } @@ -1563,13 +1523,13 @@ } }); - component._root._beforecreate.push(function () { + component.root._beforecreate.push(function () { var state = component.get(), childState = valueeditor.get(), newState = {}; if (!childState) return; if (!valueeditor_updating.value) { - state.selector[clause_1.key] = childState.value; + state.selector[clause.key] = childState.value; newState.selector = state.selector; newState.clausesKeysTypes = state.clausesKeysTypes; } @@ -1600,15 +1560,15 @@ valueeditor._mount(div, null); }, - p: function update(changed, state, clausesKeysTypes_1, clause_1, clause_index) { + p: function update(changed, state, clausesKeysTypes_1, clause, clause_index) { var valueeditor_changes = {}; - if (changed.clausesKeysTypes) valueeditor_changes.valueTypeInitial = clause_1.type.type; - if (changed.clausesKeysTypes) valueeditor_changes.allowedTypes = clause_1.type.allowedTypes; + if (changed.clausesKeysTypes) valueeditor_changes.valueTypeInitial = clause.type.type; + if (changed.clausesKeysTypes) valueeditor_changes.allowedTypes = clause.type.allowedTypes; if (changed.classCheckbox) valueeditor_changes.classCheckbox = state.classCheckbox; if (changed.classInput) valueeditor_changes.classInput = state.classInput; if (changed.classSelect) valueeditor_changes.classSelect = state.classSelect; if (!valueeditor_updating.value && changed.selector || changed.clausesKeysTypes) { - valueeditor_changes.value = state.selector[clause_1.key]; + valueeditor_changes.value = state.selector[clause.key]; valueeditor_updating.value = true; } valueeditor._set(valueeditor_changes); @@ -1630,7 +1590,7 @@ } // (47:8) {{#if clause.type === "selector"}} - function create_if_block_1(state, clausesKeysTypes_1, clause_1, clause_index, component) { + function create_if_block_1(state, clausesKeysTypes_1, clause, clause_index, component) { var selectoreditor_updating = {}; var selectoreditor_initial_data = { @@ -1640,18 +1600,18 @@ classAddButton: state.classAddButton, classRemoveButton: state.classRemoveButton }; - if (clause_1.key in state.selector) { - selectoreditor_initial_data.selector = state.selector[clause_1.key]; + if (clause.key in state.selector) { + selectoreditor_initial_data.selector = state.selector[clause.key]; selectoreditor_updating.selector = true; } var selectoreditor = new SelectorEditor({ - _root: component._root, + root: component.root, data: selectoreditor_initial_data, _bind: function _bind(changed, childState) { var state = component.get(), newState = {}; if (!selectoreditor_updating.selector && changed.selector) { - state.selector[clause_1.key] = childState.selector; + state.selector[clause.key] = childState.selector; newState.selector = state.selector; newState.clausesKeysTypes = state.clausesKeysTypes; } @@ -1661,13 +1621,13 @@ } }); - component._root._beforecreate.push(function () { + component.root._beforecreate.push(function () { var state = component.get(), childState = selectoreditor.get(), newState = {}; if (!childState) return; if (!selectoreditor_updating.selector) { - state.selector[clause_1.key] = childState.selector; + state.selector[clause.key] = childState.selector; newState.selector = state.selector; newState.clausesKeysTypes = state.clausesKeysTypes; } @@ -1681,13 +1641,13 @@ clause_index = selectoreditor_context.clause_index, clause = clausesKeysTypes_1[clause_index]; - component.removeSelector(clause_1.key); + component.removeSelector(clause.key); }); var selectoreditor_context = { - state: state, clausesKeysTypes_1: clausesKeysTypes_1, - clause_index: clause_index + clause_index: clause_index, + state: state }; return { @@ -1699,7 +1659,7 @@ selectoreditor._mount(target, anchor); }, - p: function update(changed, state, clausesKeysTypes_1, clause_1, clause_index) { + p: function update(changed, state, clausesKeysTypes_1, clause, clause_index) { var selectoreditor_changes = {}; if (changed.classCheckbox) selectoreditor_changes.classCheckbox = state.classCheckbox; if (changed.classInput) selectoreditor_changes.classInput = state.classInput; @@ -1707,15 +1667,15 @@ if (changed.classAddButton) selectoreditor_changes.classAddButton = state.classAddButton; if (changed.classRemoveButton) selectoreditor_changes.classRemoveButton = state.classRemoveButton; if (!selectoreditor_updating.selector && changed.selector || changed.clausesKeysTypes) { - selectoreditor_changes.selector = state.selector[clause_1.key]; + selectoreditor_changes.selector = state.selector[clause.key]; selectoreditor_updating.selector = true; } selectoreditor._set(selectoreditor_changes); selectoreditor_updating = {}; - selectoreditor_context.state = state; selectoreditor_context.clausesKeysTypes_1 = clausesKeysTypes_1; selectoreditor_context.clause_index = clause_index; + selectoreditor_context.state = state; }, u: function unmount() { @@ -1729,11 +1689,11 @@ } // (56:8) {{else}} - function create_if_block_2(state, clausesKeysTypes_1, clause_1, clause_index, component) { + function create_if_block_2(state, clausesKeysTypes_1, clause, clause_index, component) { var div, button, text_2, text_3; - var current_block_type = select_block_type_1(state, clausesKeysTypes_1, clause_1, clause_index); - var if_block = current_block_type(state, clausesKeysTypes_1, clause_1, clause_index, component); + var current_block_type = select_block_type_1(state, clausesKeysTypes_1, clause, clause_index); + var if_block = current_block_type(state, clausesKeysTypes_1, clause, clause_index, component); return { c: function create() { @@ -1765,7 +1725,7 @@ insertNode(text_3, target, anchor); }, - p: function update(changed, state, clausesKeysTypes_1, clause_1, clause_index) { + p: function update(changed, state, clausesKeysTypes_1, clause, clause_index) { if (changed.classAddButton) { button.className = state.classAddButton; } @@ -1773,12 +1733,12 @@ button._svelte.clausesKeysTypes_1 = clausesKeysTypes_1; button._svelte.clause_index = clause_index; - if (current_block_type === (current_block_type = select_block_type_1(state, clausesKeysTypes_1, clause_1, clause_index)) && if_block) { - if_block.p(changed, state, clausesKeysTypes_1, clause_1, clause_index); + if (current_block_type === (current_block_type = select_block_type_1(state, clausesKeysTypes_1, clause, clause_index)) && if_block) { + if_block.p(changed, state, clausesKeysTypes_1, clause, clause_index); } else { if_block.u(); if_block.d(); - if_block = current_block_type(state, clausesKeysTypes_1, clause_1, clause_index, component); + if_block = current_block_type(state, clausesKeysTypes_1, clause, clause_index, component); if_block.c(); if_block.m(text_3.parentNode, text_3); } @@ -1799,7 +1759,7 @@ } // (123:6) {{#if clause.type !== "selector"}} - function create_if_block_8(state, clausesKeysTypes_1, clause_1, clause_index, component) { + function create_if_block_8(state, clausesKeysTypes_1, clause, clause_index, component) { var div, button; return { @@ -1811,7 +1771,6 @@ }, h: function hydrate() { - div.className = "remove"; button.className = state.classRemoveButton; addListener(button, "click", click_handler_3); @@ -1820,6 +1779,8 @@ clausesKeysTypes_1: clausesKeysTypes_1, clause_index: clause_index }; + + div.className = "remove"; }, m: function mount(target, anchor) { @@ -1827,7 +1788,7 @@ appendNode(button, div); }, - p: function update(changed, state, clausesKeysTypes_1, clause_1, clause_index) { + p: function update(changed, state, clausesKeysTypes_1, clause, clause_index) { if (changed.classRemoveButton) { button.className = state.classRemoveButton; } @@ -1850,23 +1811,23 @@ var component = this._svelte.component; var clausesKeysTypes_1 = this._svelte.clausesKeysTypes_1, clause_index = this._svelte.clause_index, - clause_1 = clausesKeysTypes_1[clause_index]; - component.addClauseEntry(clause_1.key); + clause = clausesKeysTypes_1[clause_index]; + component.addClauseEntry(clause.key); } function click_handler_1(event) { var component = this._svelte.component; var clausesKeysTypes_1 = this._svelte.clausesKeysTypes_1, clause_index = this._svelte.clause_index, - clause_1 = clausesKeysTypes_1[clause_index]; + clause = clausesKeysTypes_1[clause_index]; var each_value = this._svelte.each_value, index = this._svelte.index, clauseEntry = each_value[index]; - component.removeClauseEntry(clause_1.key, index); + component.removeClauseEntry(clause.key, index); } - function select_block_type(state, clausesKeysTypes_1, clause_1, clause_index) { - if (state.isCompoundVectorClauseKeys[clause_1.key]) return create_if_block_4; + function select_block_type(state, clausesKeysTypes_1, clause, clause_index) { + if (state.isCompoundVectorClauseKeys[clause.key]) return create_if_block_4; return create_if_block_5; } @@ -1874,21 +1835,21 @@ var component = this._svelte.component; var clausesKeysTypes_1 = this._svelte.clausesKeysTypes_1, clause_index = this._svelte.clause_index, - clause_1 = clausesKeysTypes_1[clause_index]; + clause = clausesKeysTypes_1[clause_index]; var each_value = this._svelte.each_value, index = this._svelte.index, - clauseEntry_1 = each_value[index]; - component.removeClauseEntry(clause_1.key, index); + clauseEntry = each_value[index]; + component.removeClauseEntry(clause.key, index); } - function select_block_type_1(state, clausesKeysTypes_1, clause_1, clause_index) { - if (clause_1.type.vector) return create_if_block_3; - if (state.isCompoundScalarClauseKeys[clause_1.key]) return create_if_block_6; + function select_block_type_1(state, clausesKeysTypes_1, clause, clause_index) { + if (clause.type.vector) return create_if_block_3; + if (state.isCompoundScalarClauseKeys[clause.key]) return create_if_block_6; return create_if_block_7; } - function select_block_type_2(state, clausesKeysTypes_1, clause_1, clause_index) { - if (clause_1.type === "selector") return create_if_block_1; + function select_block_type_2(state, clausesKeysTypes_1, clause, clause_index) { + if (clause.type === "selector") return create_if_block_1; return create_if_block_2; } @@ -1896,8 +1857,8 @@ var component = this._svelte.component; var clausesKeysTypes_1 = this._svelte.clausesKeysTypes_1, clause_index = this._svelte.clause_index, - clause_1 = clausesKeysTypes_1[clause_index]; - component.removeClause(clause_1.key); + clause = clausesKeysTypes_1[clause_index]; + component.removeClause(clause.key); } function SelectorEditor(options) { @@ -1907,7 +1868,7 @@ if (!document.getElementById("svelte-2783728598-style")) add_css(); - if (!options._root) { + if (!options.root) { this._oncreate = []; this._beforecreate = []; this._aftercreate = []; @@ -1961,6 +1922,11 @@ target.appendChild(node); } + function selectValue(select) { + var selectedOption = select.querySelector(':checked') || select.options[0]; + return selectedOption && selectedOption.__value; + } + function createText(data) { return document.createTextNode(data); } @@ -1973,6 +1939,17 @@ target.insertBefore(node, anchor); } + function selectOption(select, value) { + for (var i = 0; i < select.options.length; i += 1) { + var option = select.options[i]; + + if (option.__value === value) { + option.selected = true; + return; + } + } + } + function detachNode(node) { node.parentNode.removeChild(node); } @@ -2009,12 +1986,13 @@ } function init(component, options) { - component.options = options; - component._observers = { pre: blankObject(), post: blankObject() }; component._handlers = blankObject(); - component._root = options._root || component; component._bind = options._bind; + + component.options = options; + component.root = options.root || component; + component.store = component.root.options.store; } function callAll(fns) { @@ -2081,12 +2059,12 @@ function set(newState) { this._set(assign({}, newState)); - if (this._root._lock) return; - this._root._lock = true; - callAll(this._root._beforecreate); - callAll(this._root._oncreate); - callAll(this._root._aftercreate); - this._root._lock = false; + if (this.root._lock) return; + this.root._lock = true; + callAll(this.root._beforecreate); + callAll(this.root._oncreate); + callAll(this.root._aftercreate); + this.root._lock = false; } function _set(newState) { @@ -2102,9 +2080,12 @@ this._state = assign({}, oldState, newState); this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); - dispatchObservers(this, this._observers.pre, changed, this._state, oldState); - this._fragment.p(changed, this._state); - dispatchObservers(this, this._observers.post, changed, this._state, oldState); + + if (this._fragment) { + dispatchObservers(this, this._observers.pre, changed, this._state, oldState); + this._fragment.p(changed, this._state); + dispatchObservers(this, this._observers.post, changed, this._state, oldState); + } } function _mount(target, anchor) { @@ -2112,7 +2093,7 @@ } function _unmount() { - this._fragment.u(); + if (this._fragment) this._fragment.u(); } function differs(a, b) { diff --git a/lib/ValueEditor.js b/lib/ValueEditor.js index 647f4ca..12db1aa 100644 --- a/lib/ValueEditor.js +++ b/lib/ValueEditor.js @@ -23,7 +23,7 @@ return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; - /* src/ValueEditor.html generated by Svelte v1.41.2 */ + /* src/ValueEditor.html generated by Svelte v1.48.0 */ var strtotime = window.strtotime; @@ -252,12 +252,12 @@ // (4:6) {{#if allowedTypes.indexOf("string") > -1}} function create_if_block_1(state, component) { - var option; + var option, text; return { c: function create() { option = createElement("option"); - option.textContent = "String"; + text = createText("String"); this.h(); }, @@ -268,6 +268,7 @@ m: function mount(target, anchor) { insertNode(option, target, anchor); + appendNode(text, option); }, u: function unmount() { @@ -280,12 +281,12 @@ // (9:6) {{#if allowedTypes.indexOf("int") > -1}} function create_if_block_2(state, component) { - var option; + var option, text; return { c: function create() { option = createElement("option"); - option.textContent = "Integer"; + text = createText("Integer"); this.h(); }, @@ -296,6 +297,7 @@ m: function mount(target, anchor) { insertNode(option, target, anchor); + appendNode(text, option); }, u: function unmount() { @@ -308,12 +310,12 @@ // (14:6) {{#if allowedTypes.indexOf("float") > -1}} function create_if_block_3(state, component) { - var option; + var option, text; return { c: function create() { option = createElement("option"); - option.textContent = "Float"; + text = createText("Float"); this.h(); }, @@ -324,6 +326,7 @@ m: function mount(target, anchor) { insertNode(option, target, anchor); + appendNode(text, option); }, u: function unmount() { @@ -336,12 +339,12 @@ // (19:6) {{#if allowedTypes.indexOf("boolean") > -1}} function create_if_block_4(state, component) { - var option; + var option, text; return { c: function create() { option = createElement("option"); - option.textContent = "Boolean"; + text = createText("Boolean"); this.h(); }, @@ -352,6 +355,7 @@ m: function mount(target, anchor) { insertNode(option, target, anchor); + appendNode(text, option); }, u: function unmount() { @@ -364,12 +368,12 @@ // (24:6) {{#if allowedTypes.indexOf("date") > -1}} function create_if_block_5(state, component) { - var option; + var option, text; return { c: function create() { option = createElement("option"); - option.textContent = "Date"; + text = createText("Date"); this.h(); }, @@ -380,6 +384,7 @@ m: function mount(target, anchor) { insertNode(option, target, anchor); + appendNode(text, option); }, u: function unmount() { @@ -413,8 +418,7 @@ function select_change_handler() { select_updating = true; - var selectedOption = select.querySelector(':checked') || select.options[0]; - component.set({ valueTypeCurrent: selectedOption && selectedOption.__value }); + component.set({ valueTypeCurrent: selectValue(select) }); select_updating = false; } @@ -440,11 +444,9 @@ }, h: function hydrate() { - select.className = state.classSelect; - - if (!('valueTypeCurrent' in state)) component._root._beforecreate.push(select_change_handler); - addListener(select, "change", select_change_handler); + if (!('valueTypeCurrent' in state)) component.root._beforecreate.push(select_change_handler); + select.className = state.classSelect; addListener(select, "change", change_handler); }, @@ -461,15 +463,7 @@ appendNode(if_block_3_anchor, select); if (if_block_4) if_block_4.m(select, null); - var value = state.valueTypeCurrent; - for (var i = 0; i < select.options.length; i += 1) { - var option = select.options[i]; - - if (option.__value === value) { - option.selected = true; - break; - } - } + selectOption(select, state.valueTypeCurrent); insertNode(text_1, target, anchor); }, @@ -535,21 +529,10 @@ if_block_4 = null; } + if (!select_updating) selectOption(select, state.valueTypeCurrent); if (changed.classSelect) { select.className = state.classSelect; } - - if (!select_updating) { - var value = state.valueTypeCurrent; - for (var i = 0; i < select.options.length; i += 1) { - var option = select.options[i]; - - if (option.__value === value) { - option.selected = true; - break; - } - } - } }, u: function unmount() { @@ -635,9 +618,9 @@ }, h: function hydrate() { + addListener(input, "input", input_input_handler); input.className = state.classInput; input.type = "text"; - addListener(input, "input", input_input_handler); }, m: function mount(target, anchor) { @@ -647,13 +630,10 @@ }, p: function update(changed, state) { + if (!input_updating) input.value = state.value; if (changed.classInput) { input.className = state.classInput; } - - if (!input_updating) { - input.value = state.value; - } }, u: function unmount() { @@ -688,9 +668,9 @@ }, h: function hydrate() { + addListener(input, "input", input_input_handler); input.className = state.classInput; input.type = "number"; - addListener(input, "input", input_input_handler); addListener(input, "input", input_handler); }, @@ -701,13 +681,10 @@ }, p: function update(changed, state) { + if (!input_updating) input.value = state.value; if (changed.classInput) { input.className = state.classInput; } - - if (!input_updating) { - input.value = state.value; - } }, u: function unmount() { @@ -739,9 +716,9 @@ }, h: function hydrate() { + addListener(input, "input", input_input_handler); input.className = state.classInput; input.type = "number"; - addListener(input, "input", input_input_handler); }, m: function mount(target, anchor) { @@ -751,13 +728,10 @@ }, p: function update(changed, state) { + if (!input_updating) input.value = state.value; if (changed.classInput) { input.className = state.classInput; } - - if (!input_updating) { - input.value = state.value; - } }, u: function unmount() { @@ -792,9 +766,9 @@ }, h: function hydrate() { + addListener(input, "change", input_change_handler); input.className = state.classCheckbox; input.type = "checkbox"; - addListener(input, "change", input_change_handler); }, m: function mount(target, anchor) { @@ -809,12 +783,11 @@ }, p: function update(changed, state) { + input.checked = state.value; if (changed.classCheckbox) { input.className = state.classCheckbox; } - input.checked = state.value; - if (current_block_type !== (current_block_type = select_block_type(state))) { if_block.u(); if_block.d(); @@ -847,8 +820,8 @@ abbr; function input_input_handler() { - input_updating = true; var state = component.get(); + input_updating = true; state.wholeEntry[2] = input.value; component.set({ wholeEntry: state.wholeEntry }); input_updating = false; @@ -871,11 +844,11 @@ }, h: function hydrate() { + addListener(input, "input", input_input_handler); input.className = state.classInput; input.type = "text"; input.placeholder = "Enter a date in basically any format, including things like \"now\", \"last friday\", \"+1 week\", and \"oct 12, 2017 3:00 pm\""; input.title = "Enter a date in basically any format, including things like \"now\", \"last friday\", \"+1 week\", and \"oct 12, 2017 3:00 pm\""; - addListener(input, "input", input_input_handler); addListener(input, "input", input_handler); code.className = "date-interpretation"; abbr.title = "This interpretation may be inaccurate, as PHP's strtotime function may return slightly different results, and the server may be using a different timezone."; @@ -894,14 +867,11 @@ }, p: function update(changed, state) { + if (!input_updating) input.value = state.wholeEntry[2]; if (changed.classInput) { input.className = state.classInput; } - if (!input_updating) { - input.value = state.wholeEntry[2]; - } - if (changed.__dateInputInterpretation) { text_1.data = state.__dateInputInterpretation; } @@ -945,11 +915,11 @@ var _oncreate = oncreate.bind(this); - if (!options._root) { + if (!options.root) { this._oncreate = [_oncreate]; this._beforecreate = []; } else { - this._root._oncreate.push(_oncreate); + this.root._oncreate.push(_oncreate); } this._fragment = create_main_fragment(this._state, this); @@ -1004,6 +974,11 @@ function noop() {} + function selectValue(select) { + var selectedOption = select.querySelector(':checked') || select.options[0]; + return selectedOption && selectedOption.__value; + } + function createComment() { return document.createComment(''); } @@ -1012,6 +987,17 @@ node.addEventListener(event, handler, false); } + function selectOption(select, value) { + for (var i = 0; i < select.options.length; i += 1) { + var option = select.options[i]; + + if (option.__value === value) { + option.selected = true; + return; + } + } + } + function removeListener(node, event, handler) { node.removeEventListener(event, handler, false); } @@ -1021,12 +1007,13 @@ } function init(component, options) { - component.options = options; - component._observers = { pre: blankObject(), post: blankObject() }; component._handlers = blankObject(); - component._root = options._root || component; component._bind = options._bind; + + component.options = options; + component.root = options.root || component; + component.store = component.root.options.store; } function assign(target) { @@ -1108,12 +1095,12 @@ function set(newState) { this._set(assign({}, newState)); - if (this._root._lock) return; - this._root._lock = true; - callAll(this._root._beforecreate); - callAll(this._root._oncreate); - callAll(this._root._aftercreate); - this._root._lock = false; + if (this.root._lock) return; + this.root._lock = true; + callAll(this.root._beforecreate); + callAll(this.root._oncreate); + callAll(this.root._aftercreate); + this.root._lock = false; } function _set(newState) { @@ -1129,9 +1116,12 @@ this._state = assign({}, oldState, newState); this._recompute(changed, this._state); if (this._bind) this._bind(changed, this._state); - dispatchObservers(this, this._observers.pre, changed, this._state, oldState); - this._fragment.p(changed, this._state); - dispatchObservers(this, this._observers.post, changed, this._state, oldState); + + if (this._fragment) { + dispatchObservers(this, this._observers.pre, changed, this._state, oldState); + this._fragment.p(changed, this._state); + dispatchObservers(this, this._observers.post, changed, this._state, oldState); + } } function _mount(target, anchor) { @@ -1139,7 +1129,7 @@ } function _unmount() { - this._fragment.u(); + if (this._fragment) this._fragment.u(); } function differs(a, b) { diff --git a/package-lock.json b/package-lock.json index 4496f3e..1a43da0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "nymph-query-editor", - "version": "1.1.2", + "version": "1.1.3", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -2548,9 +2548,9 @@ "dev": true }, "svelte": { - "version": "1.41.2", - "resolved": "https://registry.npmjs.org/svelte/-/svelte-1.41.2.tgz", - "integrity": "sha512-KlL8oOJ/VEzqRXBXvsug0Yfdyv8AELDY3XJbMp7q+sL/bobEIkT4UmNXd1zZq3txebLh1ntzqPVhnmb4IaXmxQ==", + "version": "1.48.0", + "resolved": "https://registry.npmjs.org/svelte/-/svelte-1.48.0.tgz", + "integrity": "sha512-EmWi66gC3EyNBS4Op6/SH+ysEUQb5ecRAXRR438AKqKDQk72fkKdkSHAhBjU/D58NqZBoRZhEJKzqS2Vfqg+Mw==", "dev": true }, "svelte-cli": { @@ -2559,7 +2559,7 @@ "integrity": "sha512-NV3+Z3xAHQzBd/Mn+kDWYqaqlW49alHy6CZakMEA0sYWUPMLy9FvByOlZ6TcquJop33zX32S7MTetFti4lEcWA==", "dev": true, "requires": { - "svelte": "1.41.2" + "svelte": "1.48.0" } }, "to-fast-properties": { diff --git a/package.json b/package.json index dc875cf..651f121 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nymph-query-editor", - "version": "1.1.2", + "version": "1.1.3", "description": "A Nymph query editor built with Svelte.", "directories": { "lib": "lib" @@ -32,6 +32,7 @@ "babel-plugin-transform-es2015-modules-umd": "^6.24.1", "babel-preset-env": "^1.6.1", "babel-preset-stage-3": "^6.24.1", + "svelte": "^1.48.0", "svelte-cli": "^1.4.0" }, "dependencies": {