Skip to content

Commit e7e8779

Browse files
committed
Switch poll timing to use dash, not dot.
1 parent 4985fea commit e7e8779

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

django_unicorn/static/js/element.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,13 @@ export class Element {
4545
this.model.debounceTime = attribute.modifiers.debounce ? parseInt(attribute.modifiers.debounce, 10) || -1 : -1;
4646
} else if (attribute.isPoll) {
4747
this.poll.method = attribute.value ? attribute.value : "refresh";
48-
this.poll.timing = parseInt(Object.keys(attribute.modifiers)[0], 10) || 2000;
48+
this.poll.timing = 2000;
49+
50+
const pollArgs = attribute.name.split("-").slice(1);
51+
52+
if (pollArgs.length > 0) {
53+
this.poll.timing = parseInt(pollArgs[0], 10) || 2000;
54+
}
4955
} else if (attribute.eventType) {
5056
const action = {};
5157
action.name = attribute.value;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div unicorn:poll.1000="get_date">
1+
<div unicorn:poll-1000="get_date">
22
<input unicorn:model="date_example" type="text" id="dateExampleId">
33
date_example: {{ date_example }} | {{ date_example|date:"s" }}<br />
44
</div>

tests/js/element/poll.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ test("poll", (t) => {
99
t.is(element.poll.timing, 2000);
1010
});
1111

12-
test("poll.1000", (t) => {
13-
const html = "<div unicorn:poll.1000='test()'></div>";
12+
test("poll-1000", (t) => {
13+
const html = "<div unicorn:poll-1000='test()'></div>";
1414
const element = getElement(html);
1515

1616
t.is(element.poll.timing, 1000);

0 commit comments

Comments
 (0)