Skip to content
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

Next major #1069

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/core/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ class ArgumentParser {
}
const _parse = this._parse.bind(this);
if (data.match(/&&/)) {
frame = data.split(/\s*&&\s*/).map(_parse);
frame = data.split(/\s+&&\s+/).map(_parse);
} else {
frame = _parse(data);
}
Expand Down
6 changes: 2 additions & 4 deletions src/core/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,8 @@ const registry = {
return (
!el.matches(".disable-patterns") &&
!el?.parentNode?.closest?.(".disable-patterns") &&
!el?.parentNode?.closest?.("pre") &&
!el?.parentNode?.closest?.("template") && // NOTE: not strictly necessary. Template is a DocumentFragment and not reachable except for IE.
!el.matches(".cant-touch-this") && // BBB. TODO: Remove with next major version.
!el?.parentNode?.closest?.(".cant-touch-this") // BBB. TODO: Remove with next major version.
!el?.parentNode?.closest?.("pre")
//!el?.parentNode?.closest?.("template") && // NOTE: not strictly necessary. Template is a DocumentFragment and not reachable except for IE.
);
});

Expand Down
29 changes: 1 addition & 28 deletions src/pat/inject/inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -416,39 +416,14 @@ const inject = {
return $target;
},

stopBubblingFromRemovedElement($el, cfgs, ev) {
/* IE8 fix. Stop event from propagating IF $el will be removed
* from the DOM. With pat-inject, often $el is the target that
* will itself be replaced with injected content.
*
* IE8 cannot handle events bubbling up from an element removed
* from the DOM.
*
* See: http://stackoverflow.com/questions/7114368/why-is-jquery-remove-throwing-attr-exception-in-ie8
*/
for (const cfg of cfgs) {
const sel = cfg.target;
if ($el.parents(sel).addBack(sel) && !ev.isPropagationStopped()) {
ev.stopPropagation();
return;
}
}
},

_performInjection(target, $el, $source, cfg, trigger, title) {
/* Called after the XHR has succeeded and we have a new $source
* element to inject.
*/
if (cfg.sourceMod === "content") {
$source = $source.contents();
}
let $src;
// $source.clone() does not work with shived elements in IE8
if (document.all && document.querySelector && !document.addEventListener) {
$src = $source.map((idx, el) => $(el.outerHTML)[0]);
} else {
$src = $source.safeClone();
}
const $src = $source.safeClone();

$src.findInclusive("img").on("load", (e) => {
$(e.currentTarget).trigger("pat-inject-content-loaded");
Expand Down Expand Up @@ -491,7 +466,6 @@ const inject = {
*/
$injected
.filter((idx, el_) => {
// setting data on textnode fails in IE8
return el_.nodeType !== TEXT_NODE;
})
.data("pat-injected", { origin: cfg.url });
Expand Down Expand Up @@ -591,7 +565,6 @@ const inject = {
$.each(cfgs[0].hooks || [], (idx, hook) =>
$el.trigger("pat-inject-hook-" + hook)
);
this.stopBubblingFromRemovedElement($el, cfgs, ev);
const sources$ = await this.callTypeHandler(cfgs[0].dataType, "sources", $el, [
cfgs,
data,
Expand Down