@itrocks/table 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/link.d.ts +1 -1
- package/link.js +5 -4
- package/package.json +1 -1
package/link.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export declare class TableLink extends Plugin<Table, Options> {
|
|
|
23
23
|
} | undefined;
|
|
24
24
|
protected getId(target: Element, attribute: string): {
|
|
25
25
|
element: Element;
|
|
26
|
-
value: string
|
|
26
|
+
value: string;
|
|
27
27
|
} | undefined;
|
|
28
28
|
init(): void;
|
|
29
29
|
onClick(event: MouseEvent): void;
|
package/link.js
CHANGED
|
@@ -5,7 +5,7 @@ class Options extends PluginOptions {
|
|
|
5
5
|
href = 'data-href';
|
|
6
6
|
id = 'data-id';
|
|
7
7
|
link = function (href, id) {
|
|
8
|
-
return id ? (href + (
|
|
8
|
+
return id ? (href + (href.endsWith('/') ? '' : '/') + id) : href;
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
11
|
export class TableLink extends Plugin {
|
|
@@ -48,8 +48,9 @@ export class TableLink extends Plugin {
|
|
|
48
48
|
}
|
|
49
49
|
getId(target, attribute) {
|
|
50
50
|
const element = target.closest('[' + attribute + ']');
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
const value = element?.getAttribute(attribute);
|
|
52
|
+
if (element && value)
|
|
53
|
+
return { element, value };
|
|
53
54
|
}
|
|
54
55
|
init() {
|
|
55
56
|
for (const tBody of Array.from(this.of.element.tBodies)) {
|
|
@@ -71,6 +72,6 @@ export class TableLink extends Plugin {
|
|
|
71
72
|
: this.getHref(target, this.options.href, cell, id?.element);
|
|
72
73
|
if (!href)
|
|
73
74
|
return;
|
|
74
|
-
this.options.call(
|
|
75
|
+
this.options.call(this.options.link(href.value, id?.value));
|
|
75
76
|
}
|
|
76
77
|
}
|
package/package.json
CHANGED