进行了一些小修复
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -1,25 +0,0 @@
|
||||
/**
|
||||
* Passive event listener polyfill
|
||||
*
|
||||
* Patches addEventListener so scroll-blocking events (touchstart, touchmove,
|
||||
* wheel, mousewheel) default to { passive: true } unless explicitly set to
|
||||
* false. Eliminates Chrome Violation warnings from third-party libraries.
|
||||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
var opts = Object.defineProperty({}, 'passive', {
|
||||
get: function () { window.__passiveSupported = true; }
|
||||
});
|
||||
window.addEventListener('test', null, opts);
|
||||
if (!window.__passiveSupported) return;
|
||||
|
||||
var orig = EventTarget.prototype.addEventListener;
|
||||
var passiveEvents = { touchstart: 1, touchmove: 1, wheel: 1, mousewheel: 1 };
|
||||
|
||||
EventTarget.prototype.addEventListener = function (type, listener, options) {
|
||||
if (passiveEvents[type] && typeof options !== 'object') {
|
||||
options = { passive: true, capture: options };
|
||||
}
|
||||
orig.call(this, type, listener, options);
|
||||
};
|
||||
})();
|
||||
@@ -27,7 +27,6 @@ class Scripts {
|
||||
public function init(): void {
|
||||
add_action('wp_enqueue_scripts', [$this, 'enqueue_public']);
|
||||
add_action('admin_enqueue_scripts', [$this, 'enqueue_admin']);
|
||||
add_action('admin_enqueue_scripts', [$this, 'enqueue_passive_polyfill'], 1);
|
||||
add_action('wp_head', [$this, 'inline_css_vars']);
|
||||
add_action('wp_head', [$this, 'output_custom_codes']);
|
||||
add_action('wp_body_open', [$this, 'output_loading_overlay'], 1);
|
||||
|
||||
@@ -30,19 +30,6 @@ trait ScriptsPart2 {
|
||||
wp_send_json_success(['logged' => true]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Passive event listener polyfill — 全局加载,消除 Chrome Violation 警告
|
||||
*/
|
||||
public function enqueue_passive_polyfill(): void {
|
||||
wp_enqueue_script(
|
||||
'aksrt-passive-events',
|
||||
get_template_directory_uri() . '/assets/js/passive-events.js',
|
||||
[],
|
||||
AKSRT_VERSION,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载后台资源 — 仅在 AKSRT 设置页面加载(与前端样式完全隔离)
|
||||
*/
|
||||
|
||||
@@ -64,3 +64,16 @@ test('legacy runtime modules use jQuery explicitly without a dollar alias', () =
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('theme runtime never changes native listener passivity for third-party editors', () => {
|
||||
const scripts = read('src/Core/Scripts.php');
|
||||
const scriptsPart2 = read('src/Core/ScriptsPart2.php');
|
||||
const buildTool = read('tools/build-public-assets.mjs');
|
||||
const publicRuntime = read('assets/js/build/public.js');
|
||||
|
||||
assert.doesNotMatch(scripts, /enqueue_passive_polyfill|aksrt-passive-events/);
|
||||
assert.doesNotMatch(scriptsPart2, /enqueue_passive_polyfill|aksrt-passive-events/);
|
||||
assert.doesNotMatch(buildTool, /passive-events\.js/);
|
||||
assert.doesNotMatch(publicRuntime, /EventTarget\.prototype\.addEventListener|__passiveSupported/);
|
||||
assert.equal(fs.existsSync(path.join(root, 'assets/js/passive-events.js')), false);
|
||||
});
|
||||
|
||||
@@ -60,7 +60,6 @@ const cssBundles = {
|
||||
};
|
||||
|
||||
const publicScripts = [
|
||||
'assets/js/passive-events.js',
|
||||
'assets/js/runtime/libs/bootstrap.min.js',
|
||||
'assets/js/runtime/loader.js',
|
||||
'assets/js/lazy-image-attr.js',
|
||||
|
||||
Reference in New Issue
Block a user