1
0
mirror of https://github.com/morris/vanilla-todo.git synced 2025-08-22 21:52:54 +02:00

Merge pull request #7 from opethrocks/dataset

Refactor for dataset
This commit is contained in:
Morris Brodersen
2020-10-29 12:17:46 +01:00
committed by GitHub
8 changed files with 13 additions and 15 deletions

View File

@@ -46,7 +46,7 @@ VT.AppFlip = function (el, options) {
var map = new Map();
el.querySelectorAll(options.selector).forEach(function (el) {
var key = el.getAttribute('data-key') || el;
var key = el.dataset.key || el;
// parse original transform
// i.e. strip inverse transform using "scale(1)" marker
@@ -73,7 +73,7 @@ VT.AppFlip = function (el, options) {
var current = entry.el.parentNode;
while (current && current !== el) {
var ancestor = map.get(current.getAttribute('data-key') || current);
var ancestor = map.get(current.dataset.key || current);
if (ancestor) {
entry.ancestor = ancestor;

View File

@@ -4,7 +4,7 @@ window.VT = window.VT || {};
VT.AppIcon = function (el) {
if (el.children.length > 0) return;
var id = el.getAttribute('data-id');
var id = el.dataset.id;
var promise = VT.AppIcon.cache[id];
if (!promise) {

View File

@@ -107,7 +107,7 @@ VT.AppSortable = function (el, options) {
for (var i = 0, l = el.children.length; i < l; ++i) {
var child = el.children[i];
if (child && child.getAttribute('data-key') === key) {
if (child && child.dataset.key === key) {
el.removeChild(child);
}
}

View File

@@ -133,10 +133,8 @@ VT.TodoCustomList = function (el) {
titleEl.innerText = state.list.title || '...';
el.querySelector('.todo-list').todoList.update({ items: state.list.items });
el.querySelector('.todo-list > .todo-item-input').setAttribute(
'data-key',
'todo-item-input-' + state.list.id
);
el.querySelector('.todo-list > .todo-item-input').dataset.key =
'todo-item-input' + state.list.id;
el.classList.toggle('-editing', state.editing);

View File

@@ -3,7 +3,7 @@ window.VT = window.VT || {};
VT.TodoDay = function (el) {
var state = {
dateId: el.getAttribute('data-key'),
dateId: el.dataset.key,
items: [],
};

View File

@@ -78,7 +78,7 @@ VT.TodoFrameCustom = function (el) {
var childrenByKey = new Map();
obsolete.forEach(function (child) {
childrenByKey.set(child.getAttribute('data-key'), child);
childrenByKey.set(child.dataset.key, child);
});
var children = lists.map(function (list) {
@@ -89,7 +89,7 @@ VT.TodoFrameCustom = function (el) {
} else {
child = document.createElement('div');
child.className = 'card todo-custom-list';
child.setAttribute('data-key', list.id);
child.dataset.key = list.id;
VT.TodoCustomList(child);
}

View File

@@ -61,7 +61,7 @@ VT.TodoFrameDays = function (el) {
var childrenByKey = new Map();
obsolete.forEach(function (child) {
childrenByKey.set(child.getAttribute('data-key'), child);
childrenByKey.set(child.dataset.key, child);
});
var children = days.map(function (day) {
@@ -72,7 +72,7 @@ VT.TodoFrameDays = function (el) {
} else {
child = document.createElement('div');
child.className = 'card todo-day';
child.setAttribute('data-key', day.id);
child.dataset.key = day.id;
VT.TodoDay(child);
}

View File

@@ -34,7 +34,7 @@ VT.TodoList = function (el) {
var childrenByKey = new Map();
obsolete.forEach(function (child) {
childrenByKey.set(child.getAttribute('data-key'), child);
childrenByKey.set(child.dataset.key, child);
});
var children = state.items.map(function (item) {
@@ -45,7 +45,7 @@ VT.TodoList = function (el) {
} else {
child = document.createElement('div');
child.classList.add('todo-item');
child.setAttribute('data-key', item.id);
child.dataset.key = item.id;
VT.TodoItem(child);
}