Skip to content
This repository has been archived by the owner on Dec 11, 2022. It is now read-only.

Commit

Permalink
Fix selector reference causing weird side effects.
Browse files Browse the repository at this point in the history
  • Loading branch information
hperrin committed Nov 22, 2017
1 parent 14a0dee commit 9bc0a46
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
10 changes: 6 additions & 4 deletions lib/QueryEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@
},
removeSelector: function removeSelector(index) {
var selectors = this.get("selectors");
this.set({ selectors: [] });

selectors.splice(index, 1);
this.set({ selectors: selectors });
},
Expand All @@ -160,13 +162,13 @@
};

function encapsulateStyles(node) {
setAttribute(node, "svelte-672087078", "");
setAttribute(node, "svelte-331703558", "");
}

function add_css() {
var style = createElement("style");
style.id = 'svelte-672087078-style';
style.textContent = "[svelte-672087078].query-editor,[svelte-672087078] .query-editor{font-family:monospace}[svelte-672087078].options-editor,[svelte-672087078] .options-editor,[svelte-672087078].selector-editor,[svelte-672087078] .selector-editor,[svelte-672087078].selector-editor .selector,[svelte-672087078] .selector-editor .selector{padding-left:1em;display:flex;flex-direction:column}[svelte-672087078].options-editor .option,[svelte-672087078] .options-editor .option,[svelte-672087078].selector-editor .selector .clause,[svelte-672087078] .selector-editor .selector .clause{padding:.5em 1em;display:flex;flex-direction:row}[svelte-672087078].query-result,[svelte-672087078] .query-result{border:1px solid}[svelte-672087078].query-result .query,[svelte-672087078] .query-result .query{font-family:monospace;margin:0;padding:1em;overflow:auto;max-height:200px}[svelte-672087078].help-dialog-container,[svelte-672087078] .help-dialog-container{display:flex;justify-content:center;align-items:center;position:fixed;top:0;left:0;bottom:0;right:0;z-index:1000}[svelte-672087078].help-dialog-overlay,[svelte-672087078] .help-dialog-overlay{position:absolute;top:0;left:0;bottom:0;right:0;background-color:rgba(0, 0, 0, 0.3);z-index:1}[svelte-672087078].help-dialog,[svelte-672087078] .help-dialog{display:flex;flex-direction:column;box-shadow:0px 5px 36px 0px rgba(0,0,0,0.25);background-color:#fff;padding:2em;max-height:80vh;max-width:80vw;overflow:auto;z-index:2}[svelte-672087078].help-dialog > *,[svelte-672087078] .help-dialog > *{margin-bottom:1em}[svelte-672087078].help-dialog > *:last-child,[svelte-672087078] .help-dialog > *:last-child{margin-bottom:0}[svelte-672087078].help-dialog .actions,[svelte-672087078] .help-dialog .actions{display:flex;flex-direction:row;justify-content:flex-end;align-items:center}[svelte-672087078].help-dialog .actions > *,[svelte-672087078] .help-dialog .actions > *{margin-left:1em}";
style.id = 'svelte-331703558-style';
style.textContent = "[svelte-331703558].query-editor,[svelte-331703558] .query-editor{font-family:monospace}[svelte-331703558].options-editor,[svelte-331703558] .options-editor,[svelte-331703558].selector-editor,[svelte-331703558] .selector-editor,[svelte-331703558].selector-editor .selector,[svelte-331703558] .selector-editor .selector{padding-left:1em;display:flex;flex-direction:column}[svelte-331703558].options-editor .option,[svelte-331703558] .options-editor .option,[svelte-331703558].selector-editor .selector .clause,[svelte-331703558] .selector-editor .selector .clause{padding:.5em 1em;display:flex;flex-direction:row}[svelte-331703558].query-result,[svelte-331703558] .query-result{border:1px solid}[svelte-331703558].query-result .query,[svelte-331703558] .query-result .query{font-family:monospace;margin:0;padding:1em;overflow:auto;max-height:200px}[svelte-331703558].help-dialog-container,[svelte-331703558] .help-dialog-container{display:flex;justify-content:center;align-items:center;position:fixed;top:0;left:0;bottom:0;right:0;z-index:1000}[svelte-331703558].help-dialog-overlay,[svelte-331703558] .help-dialog-overlay{position:absolute;top:0;left:0;bottom:0;right:0;background-color:rgba(0, 0, 0, 0.3);z-index:1}[svelte-331703558].help-dialog,[svelte-331703558] .help-dialog{display:flex;flex-direction:column;box-shadow:0px 5px 36px 0px rgba(0,0,0,0.25);background-color:#fff;padding:2em;max-height:80vh;max-width:80vw;overflow:auto;z-index:2}[svelte-331703558].help-dialog > *,[svelte-331703558] .help-dialog > *{margin-bottom:1em}[svelte-331703558].help-dialog > *:last-child,[svelte-331703558] .help-dialog > *:last-child{margin-bottom:0}[svelte-331703558].help-dialog .actions,[svelte-331703558] .help-dialog .actions{display:flex;flex-direction:row;justify-content:flex-end;align-items:center}[svelte-331703558].help-dialog .actions > *,[svelte-331703558] .help-dialog .actions > *{margin-left:1em}";
appendNode(style, document.head);
}

Expand Down Expand Up @@ -1392,7 +1394,7 @@
this._state = assign(data(), options.data);
this._recompute({ options: 1, supportedOptions: 1, selectors: 1 }, this._state);

if (!document.getElementById("svelte-672087078-style")) add_css();
if (!document.getElementById("svelte-331703558-style")) add_css();

if (!options._root) {
this._oncreate = [];
Expand Down
9 changes: 5 additions & 4 deletions lib/SelectorEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@
},
removeSelector: function removeSelector(key) {
var selector = this.get("selector");
this.set({ selector: { type: '&' } });

// Delete the keyed selector.
delete selector[key];
Expand All @@ -327,13 +328,13 @@
};

function encapsulateStyles(node) {
setAttribute(node, "svelte-2599719345", "");
setAttribute(node, "svelte-2783728598", "");
}

function add_css() {
var style = createElement("style");
style.id = 'svelte-2599719345-style';
style.textContent = "[svelte-2599719345].selector,[svelte-2599719345] .selector{margin:.5em;padding:.5em;display:flex;flex-direction:column;border:1px dotted}[svelte-2599719345].selector .clause,[svelte-2599719345] .selector .clause,[svelte-2599719345].selector .clause .clause-entry,[svelte-2599719345] .selector .clause .clause-entry{padding:.5em 1em;display:flex;flex-direction:row}";
style.id = 'svelte-2783728598-style';
style.textContent = "[svelte-2783728598].selector,[svelte-2783728598] .selector{margin:.5em;padding:.5em;display:flex;flex-direction:column;border:1px dotted}[svelte-2783728598].selector .clause,[svelte-2783728598] .selector .clause,[svelte-2783728598].selector .clause .clause-entry,[svelte-2783728598] .selector .clause .clause-entry{padding:.5em 1em;display:flex;flex-direction:row}";
appendNode(style, document.head);
}

Expand Down Expand Up @@ -1904,7 +1905,7 @@
this._state = assign(data(), options.data);
this._recompute({ selector: 1, supportedClauses: 1 }, this._state);

if (!document.getElementById("svelte-2599719345-style")) add_css();
if (!document.getElementById("svelte-2783728598-style")) add_css();

if (!options._root) {
this._oncreate = [];
Expand Down
2 changes: 2 additions & 0 deletions src/QueryEditor.html
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,8 @@ <h3>How to Build Nymph Queries</h3>

removeSelector (index) {
const selectors = this.get("selectors");
this.set({selectors: []});

selectors.splice(index, 1);
this.set({selectors});
},
Expand Down
1 change: 1 addition & 0 deletions src/SelectorEditor.html
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@

removeSelector (key) {
const selector = this.get("selector");
this.set({selector: {type: '&'}});

// Delete the keyed selector.
delete selector[key];
Expand Down

0 comments on commit 9bc0a46

Please sign in to comment.