Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
Wrap setDragImage
Browse files Browse the repository at this point in the history
  • Loading branch information
arv committed Mar 3, 2014
1 parent e1d3e26 commit d4a0e87
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions build.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@
"src/wrappers/Selection.js",
"src/wrappers/Document.js",
"src/wrappers/Window.js",
"src/wrappers/DataTransfer.js",
"src/wrappers/override-constructors.js"
]
1 change: 1 addition & 0 deletions shadowdom.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
'src/wrappers/Selection.js',
'src/wrappers/Document.js',
'src/wrappers/Window.js',
'src/wrappers/DataTransfer.js',
'src/wrappers/override-constructors.js'
].forEach(function(src) {
document.write('<script src="' + base + src + '"></script>');
Expand Down
24 changes: 24 additions & 0 deletions src/wrappers/DataTransfer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Copyright 2014 The Polymer Authors. All rights reserved.
* Use of this source code is goverened by a BSD-style
* license that can be found in the LICENSE file.
*/

(function(scope) {
'use strict';

var unwrap = scope.unwrap;

// DataTransfer (Clipboard in old Blink/WebKit) has a single method that
// requires wrapping. Since it is only a method we do not need a real wrapper,
// we can just override the method.

var OriginalDataTransfer = window.DataTransfer || window.Clipboard;
var OriginalDataTransferSetDragImage =
OriginalDataTransfer.prototype.setDragImage;

OriginalDataTransfer.prototype.setDragImage = function(image, x, y) {
OriginalDataTransferSetDragImage.call(this, unwrap(image), x, y);

This comment has been minimized.

Copy link
@janpaul123

janpaul123 Jul 1, 2014

This crashes when OriginalDataTransferSetDragImage does not exist, e.g. IE (http://caniuse.com/dragndrop).

This comment has been minimized.

Copy link
@arv

arv Jul 1, 2014

Author Contributor

Which version of IE? I just tried IE11 and IE dev channel.

This comment has been minimized.

Copy link
@janpaul123

janpaul123 Jul 1, 2014

Oh, 10 I believe. In that case the caniuse table should be updated, because the comment implies that setDragImage doesn't work with any version of IE.

This comment has been minimized.

Copy link
@arv

arv Jul 2, 2014

Author Contributor

I'm stupid. I tested it in an environment that loaded this file.

This comment has been minimized.

Copy link
@arv
};

})(window.ShadowDOMPolyfill);

0 comments on commit d4a0e87

Please sign in to comment.