mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-13 20:08:05 +08:00
⛅ Sync 2026-09-28 17:06:29
This commit is contained in:
1 parent
55ddf05bcd
commit
d15c668c06
138 files changed
+975
-606
No files matched your search
@@ -169,24 +169,33 @@ return baseclass.extend({
|
||||
};
|
||||
|
||||
const evalNode = function (node) {
|
||||
if (node.and) {
|
||||
const keys = Object.keys(node);
|
||||
if (keys.length !== 1)
|
||||
throw new Error(
|
||||
'CLASSIFY_SPEC node must have exactly one key: ' + JSON.stringify(node)
|
||||
);
|
||||
const key = keys[0];
|
||||
if (key === 'and') {
|
||||
if (!Array.isArray(node.and))
|
||||
throw new Error('CLASSIFY_SPEC and node must be an array');
|
||||
for (let i = 0; i < node.and.length; i++) {
|
||||
if (!evalNode(node.and[i])) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (node.or) {
|
||||
if (key === 'or') {
|
||||
if (!Array.isArray(node.or))
|
||||
throw new Error('CLASSIFY_SPEC or node must be an array');
|
||||
for (let i = 0; i < node.or.length; i++) {
|
||||
if (evalNode(node.or[i])) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
const keys = Object.keys(node);
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
const k = keys[i];
|
||||
if (pred[k]) return pred[k](node);
|
||||
}
|
||||
return false;
|
||||
if (!Object.prototype.hasOwnProperty.call(pred, key))
|
||||
throw new Error(
|
||||
'unrecognised CLASSIFY_SPEC predicate node: ' + JSON.stringify(node)
|
||||
);
|
||||
return pred[key](node);
|
||||
};
|
||||
|
||||
for (let i = 0; i < this.CLASSIFY_SPEC.rules.length; i++) {
|
||||
|
||||
@@ -320,7 +320,7 @@ function rowClass(index, row, state, callbacks) {
|
||||
.join(' ');
|
||||
}
|
||||
|
||||
function buildRow(row, index, state, columns, callbacks) {
|
||||
function buildRow(row, index, state, columns, callbacks, key) {
|
||||
const cells = [];
|
||||
for (let c = 0; c < columns.length; c++)
|
||||
cells.push(buildColumnCell(columns[c], row, state, callbacks));
|
||||
@@ -334,7 +334,7 @@ function buildRow(row, index, state, columns, callbacks) {
|
||||
cells
|
||||
);
|
||||
tr._fwliveRowId = String(row.id);
|
||||
tr._fwliveRowKey = rowRenderKey(row, state, columns);
|
||||
tr._fwliveRowKey = key === undefined ? rowRenderKey(row, state, columns) : key;
|
||||
return tr;
|
||||
}
|
||||
|
||||
@@ -398,7 +398,7 @@ function renderRows(host, state, callbacks) {
|
||||
const id = String(row.id);
|
||||
const key = rowRenderKey(row, state, columns);
|
||||
let tr = existingRows.get(id);
|
||||
if (!tr || tr._fwliveRowKey !== key) tr = buildRow(row, i, state, columns, callbacks);
|
||||
if (!tr || tr._fwliveRowKey !== key) tr = buildRow(row, i, state, columns, callbacks, key);
|
||||
else tr.setAttribute('class', rowClass(i, row, state, callbacks));
|
||||
tr._fwliveRowId = id;
|
||||
tr._fwliveRowKey = key;
|
||||
|
||||
Reference in new issue
Block a user