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

Fix tree shake by adding some /* @__PURE__ */ marks #255

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
7 changes: 4 additions & 3 deletions lib/bodyScrollLock.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ if (typeof window !== 'undefined') {
return undefined;
}
};
window.addEventListener('testPassive', null, passiveTestOptions);
window.removeEventListener('testPassive', null, passiveTestOptions);
/* @__PURE__ */window.addEventListener('testPassive', null, passiveTestOptions);
/* @__PURE__ */window.removeEventListener('testPassive', null, passiveTestOptions);
}

const isIosDevice = typeof window !== 'undefined' && window.navigator && window.navigator.platform && (/iP(ad|hone|od)/.test(window.navigator.platform) || window.navigator.platform === 'MacIntel' && window.navigator.maxTouchPoints > 1);
const isIosDevice = typeof window !== 'undefined' && window.navigator && window.navigator.platform && (
/* @__PURE__ *//iP(ad|hone|od)/.test(window.navigator.platform) || window.navigator.platform === 'MacIntel' && window.navigator.maxTouchPoints > 1);


let locks = [];
Expand Down
7 changes: 4 additions & 3 deletions lib/bodyScrollLock.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ if (typeof window !== 'undefined') {
return undefined;
}
};
window.addEventListener('testPassive', null, passiveTestOptions);
window.removeEventListener('testPassive', null, passiveTestOptions);
/* @__PURE__ */window.addEventListener('testPassive', null, passiveTestOptions);
/* @__PURE__ */window.removeEventListener('testPassive', null, passiveTestOptions);
}

var isIosDevice = typeof window !== 'undefined' && window.navigator && window.navigator.platform && (/iP(ad|hone|od)/.test(window.navigator.platform) || window.navigator.platform === 'MacIntel' && window.navigator.maxTouchPoints > 1);
var isIosDevice = typeof window !== 'undefined' && window.navigator && window.navigator.platform && (
/* @__PURE__ *//iP(ad|hone|od)/.test(window.navigator.platform) || window.navigator.platform === 'MacIntel' && window.navigator.maxTouchPoints > 1);


var locks = [];
Expand Down
7 changes: 4 additions & 3 deletions lib/bodyScrollLock.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@
return undefined;
}
};
window.addEventListener('testPassive', null, passiveTestOptions);
window.removeEventListener('testPassive', null, passiveTestOptions);
/* @__PURE__ */window.addEventListener('testPassive', null, passiveTestOptions);
/* @__PURE__ */window.removeEventListener('testPassive', null, passiveTestOptions);
}

var isIosDevice = typeof window !== 'undefined' && window.navigator && window.navigator.platform && (/iP(ad|hone|od)/.test(window.navigator.platform) || window.navigator.platform === 'MacIntel' && window.navigator.maxTouchPoints > 1);
var isIosDevice = typeof window !== 'undefined' && window.navigator && window.navigator.platform && (
/* @__PURE__ *//iP(ad|hone|od)/.test(window.navigator.platform) || window.navigator.platform === 'MacIntel' && window.navigator.maxTouchPoints > 1);


var locks = [];
Expand Down
2 changes: 1 addition & 1 deletion lib/bodyScrollLock.min.js

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

9 changes: 6 additions & 3 deletions src/bodyScrollLock.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,18 @@ if (typeof window !== 'undefined') {
return undefined;
},
};
window.addEventListener('testPassive', null, passiveTestOptions);
window.removeEventListener('testPassive', null, passiveTestOptions);
// PURE marks for bundlers so they can tree-shake this code
// if `hasPassiveEvents` is not used
/* @__PURE__ */ window.addEventListener('testPassive', null, passiveTestOptions);
/* @__PURE__ */ window.removeEventListener('testPassive', null, passiveTestOptions);
}

const isIosDevice =
typeof window !== 'undefined' &&
window.navigator &&
window.navigator.platform &&
(/iP(ad|hone|od)/.test(window.navigator.platform) ||
// PURE mark for tree-shakeability
/* @__PURE__ */ (/iP(ad|hone|od)/.test(window.navigator.platform) ||
(window.navigator.platform === 'MacIntel' && window.navigator.maxTouchPoints > 1));
type HandleScrollEvent = TouchEvent;

Expand Down