Skip to content

Commit 4d929ba

Browse files
Merge branch 'master' into master
2 parents 214aba5 + 4e32fae commit 4d929ba

File tree

4 files changed

+27
-6
lines changed

4 files changed

+27
-6
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ npm i -S vuedraggable@next
9191
components: {
9292
draggable,
9393
},
94+
data() {
95+
return {
96+
drag: false,
97+
}
98+
},
9499
...
95100
```
96101

src/util/tags.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,7 @@ function isTransition(name) {
127127
}
128128

129129
function isHtmlAttribute(value) {
130-
return (
131-
["id", "class", "style"].includes(value) ||
132-
value.startsWith("data-") ||
133-
value.startsWith("on")
134-
);
130+
return ["id", "class", "role", "style"].includes(value) || value.startsWith("data-") || value.startsWith("aria-");
135131
}
136132

137133
export { isHtmlTag, isHtmlAttribute, isTransition };

src/vuedraggable.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ const draggableComponent = defineComponent({
165165
$attrs: {
166166
handler(newOptionValue) {
167167
const { _sortable } = this;
168+
if (!_sortable) return;
168169
getValidSortableEntries(newOptionValue).forEach(([key, value]) => {
169170
_sortable.option(key, value);
170171
});

tests/unit/util/tags.spec.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { isHtmlTag, isTransition } from "@/util/tags";
1+
import { isHtmlTag, isTransition, isHtmlAttribute } from "@/util/tags";
22

33
describe("isHtmlTag", () => {
44
test.each([
@@ -17,6 +17,25 @@ describe("isHtmlTag", () => {
1717
)
1818
});
1919

20+
describe("isHtmlAttribute", () => {
21+
test.each([
22+
["class", true],
23+
["id", true],
24+
["role", true],
25+
["data-whatever", true],
26+
["aria-whatever", true],
27+
["notattribute", false],
28+
["href", false],
29+
["name", false],
30+
])(
31+
"for %s returns %s",
32+
(value, expected) =>{
33+
const actual = isHtmlAttribute(value);
34+
expect(actual).toEqual(expected);
35+
}
36+
)
37+
});
38+
2039
describe("isTransition", () => {
2140
test.each([
2241
["TransitionGroup", true],

0 commit comments

Comments
 (0)