fix(runtime): use jQuery, not bare $, in the lazily loaded clipboard lib
WordPress runs jQuery in noConflict mode, so bare $ is undefined. The clipboard module called $(this) on every click and $.isFunction on the copy result, so any click on a [data-clipboard-text] button threw "$ is not a function" and copied nothing. This was latent: the only prior emitter was the paid card, and the click path only ran when a user actually clicked it. Exposing the copy button on the download box made it reachable on every resource, surfacing the error. Bind through jQuery explicitly, guard notyf so a missing toast lib cannot also throw, and drop the _win.bd dependency (that payload only gains .bd once main.js runs). Contract-lock the module under simulated noConflict. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
bd3d50c6c6
commit
63b5edd901
3 files changed
+104
-5
No files matched your search
@@ -38,14 +38,14 @@ function copyText(text, success, error, _this) {
|
||||
}
|
||||
}
|
||||
|
||||
_win.bd.on('click', "[data-clipboard-text]", 'clipboard', function (e) {
|
||||
var _this = $(this);
|
||||
window.jQuery('body').on('click', "[data-clipboard-text]", 'clipboard', function (e) {
|
||||
var _this = jQuery(this);
|
||||
var text = _this.attr('data-clipboard-text');
|
||||
var tag = _this.attr('data-clipboard-tag') || '内容';
|
||||
|
||||
copyText(text, function () {
|
||||
notyf(tag + "已复制")
|
||||
typeof notyf === 'function' && notyf(tag + "已复制")
|
||||
}, function () {
|
||||
notyf(tag + "复制失败,请手动复制", 'danger')
|
||||
typeof notyf === 'function' && notyf(tag + "复制失败,请手动复制", 'danger')
|
||||
}, this);
|
||||
})
|
||||
Reference in new issue
Block a user