Skip to content

Update console.js to run in environments without console #280

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
799 changes: 346 additions & 453 deletions dist/vuedraggable.common.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/vuedraggable.common.js.map

Large diffs are not rendered by default.

799 changes: 346 additions & 453 deletions dist/vuedraggable.umd.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/vuedraggable.umd.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/vuedraggable.umd.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/vuedraggable.umd.min.js.map

Large diffs are not rendered by default.

8 changes: 1 addition & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
"types": "types/vuedraggable.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/SortableJS/Vue.Draggable.git"
"url": "https://github.com/BeatBroccoli/vue.draggable.next"
},
"private": false,
"scripts": {
2 changes: 1 addition & 1 deletion src/core/renderHelper.js
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ function computeNodes({ $slots, realList, getKey }) {
}
const defaultNodes = normalizedList.flatMap((element, index) =>
item({ element, index }).map(node => {
node.key = getKey(element);
node.key = getKey(element, index);
node.props = { ...(node.props || {}), "data-draggable": true };
return node;
})
8 changes: 4 additions & 4 deletions src/util/console.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
function getConsole() {
if (typeof window !== "undefined") {
return window.console;
}
return global.console;
if (typeof window !== "undefined" && window.console) return window.console;
if (global && global.console) return global.console;
return { log: function () { }, warn: function () { }, error: function () { }, info: function () { } }
}

const console = getConsole();

export { console };
15 changes: 14 additions & 1 deletion src/vuedraggable.js
Original file line number Diff line number Diff line change
@@ -65,6 +65,10 @@ const props = {
type: Object,
required: false,
default: null
},
beforeAdded: {
type: Function,
default: null
}
};

@@ -238,12 +242,21 @@ const draggableComponent = defineComponent({
},

onDragAdd(evt) {
const element = evt.item._underlying_vm_;
let element = evt.item._underlying_vm_;
if (element === undefined) {
return;
}
removeNode(evt.item);
const newIndex = this.getVmIndexFromDomIndex(evt.newIndex);

// handle element before add
if (this.beforeAdded) {
const newElement = this.beforeAdded(element);
if (newElement !== undefined) {
element = newElement;
}
}

// @ts-ignore
this.spliceList(newIndex, 0, element);
const added = { element, newIndex };
21 changes: 13 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
@@ -1479,6 +1479,11 @@
"@types/mime" "^1"
"@types/node" "*"

"@types/sortablejs@^1.10.7":
version "1.15.8"
resolved "https://registry.yarnpkg.com/@types/sortablejs/-/sortablejs-1.15.8.tgz#11ed555076046e00869a5ef85d1e7651e7a66ef6"
integrity sha512-b79830lW+RZfwaztgs1aVPgbasJ8e7AXtZYHTELNXZPsERt4ymJdjV4OccDbHQAvHrCcFpbF78jkm0R6h/pZVg==

"@types/source-list-map@*":
version "0.1.2"
resolved "https://registry.yarnpkg.com/@types/source-list-map/-/source-list-map-0.1.2.tgz#0078836063ffaf17412349bba364087e0ac02ec9"
@@ -9375,10 +9380,10 @@ sort-keys@^1.0.0:
dependencies:
is-plain-obj "^1.0.0"

sortablejs@1.10.2:
version "1.10.2"
resolved "https://registry.yarnpkg.com/sortablejs/-/sortablejs-1.10.2.tgz#6e40364d913f98b85a14f6678f92b5c1221f5290"
integrity sha512-YkPGufevysvfwn5rfdlGyrGjt7/CRHwvRPogD/lC+TnvcN29jDpCifKP+rBqf+LRldfXSTh+0CGLcSg0VIxq3A==
sortablejs@1.14.0:
version "1.14.0"
resolved "https://registry.yarnpkg.com/sortablejs/-/sortablejs-1.14.0.tgz#6d2e17ccbdb25f464734df621d4f35d4ab35b3d8"
integrity sha512-pBXvQCs5/33fdN1/39pPL0NZF20LeRbLQ5jtnheIPN9JQAaufGjKdWduZn4U7wCtVuzKhmRkI0DFYHYRbB2H1w==

source-list-map@^2.0.0:
version "2.0.1"
@@ -10119,10 +10124,10 @@ typedarray@^0.0.6:
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=

typescript@^4.0.3:
version "4.3.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.3.2.tgz#399ab18aac45802d6f2498de5054fcbbe716a805"
integrity sha512-zZ4hShnmnoVnAHpVHWpTcxdv7dWP60S2FsydQLV8V5PbS3FifjWFFRiHSWpDJahly88PRyV5teTSLoq4eG7mKw==
typescript@^4.3.5:
version "4.9.5"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.5.tgz#095979f9bcc0d09da324d58d03ce8f8374cbe65a"
integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==

uglify-js@3.4.x:
version "3.4.10"