Change: drop .last and .rotate

This commit is contained in:
eight 2018-10-14 17:56:16 +08:00
parent 85e70491e4
commit d4ddfcc713
3 changed files with 4 additions and 20 deletions

View File

@ -138,10 +138,11 @@ const cmFactory = (() => {
}
function autocompleteOnTyping(cm, [info], debounced) {
const lastLine = info.text[info.text.length - 1];
if (
cm.state.completionActive ||
info.origin && !info.origin.includes('input') ||
!info.text.last
!lastLine
) {
return;
}
@ -153,7 +154,7 @@ const cmFactory = (() => {
debounce(autocompleteOnTyping, 100, cm, [info], true);
return;
}
if (info.text.last.match(/[-a-z!]+$/i)) {
if (lastLine.match(/[-a-z!]+$/i)) {
cm.state.autocompletePicked = false;
cm.options.hintOptions.completeSingle = false;
cm.execCommand('autocomplete');

View File

@ -476,6 +476,7 @@ function createSectionsEditor(style) {
function removeSection(section) {
if (sections.every(s => s.isRemoved() || s === section)) {
// TODO: hide remove button when `#sections[data-section-count=1]`
throw new Error('Cannot remove last section');
}
if (section.cm.isBlank()) {
@ -534,7 +535,6 @@ function createSectionsEditor(style) {
container.appendChild(section.el);
}
section.render();
// maximizeCodeHeight(section.el);
updateSectionOrder();
section.onChange(updateLivePreview);
updateLivePreview();

View File

@ -13,23 +13,6 @@ if (!/^Win\d+/.test(navigator.platform)) {
NodeList.prototype[method] = Array.prototype[method];
});
// eslint-disable-next-line no-extend-native
Object.defineProperties(Array.prototype, {
last: {
get() {
return this[this.length - 1];
},
},
rotate: {
value: function (amount) {
// negative amount == rotate left
const r = this.slice(-amount, this.length);
Array.prototype.push.apply(r, this.slice(0, this.length - r.length));
return r;
},
},
});
// polyfill for old browsers to enable [...results] and for-of
for (const type of [NodeList, NamedNodeMap, HTMLCollection, HTMLAllCollection]) {
if (!type.prototype[Symbol.iterator]) {