// select the last item when you backspace from the add-items field function selectLastItem(e) { var data = observer.value(), newItems = dom.findAll(boundEl, '.simple-list-item'); if (!addEl.value || !addEl.value.length) { e.preventDefault(); // prevent triggering the browser's back button _.last(data)._selected = true; _.last(newItems).focus(); // focus on the last item observer.setValue(data); } }
export function getFieldEl(uri, path) { const selectors = fieldSelectors(uri, path), el = find(selectors[0]) || find(selectors[1]); // find field in normal components if (el) { return el; } else { // attempt to find field in layout, // by checking all the fields that match and returning the first one // that is NOT inside a component (the field whose closest data-uri node is actually <html>) return _.find(findAll(selectors[2]), (fieldEl) => closest(fieldEl, `[${refAttr}]`) === document.firstElementChild); } }
export function getVisibleList(doc) { doc = doc || /* istanbul ignore next */ document.body; return _.filter(findAll(doc, `[${refAttr}]`), showVisible); }
/** * Saves unique values only * @returns {Array} */ function getLatestRefMap() { return _.uniq(_.map(dom.findAll(refAtrrSelector), function (el) { return el.getAttribute(refAttr); })); }