Skip to content

Fix for makeClipping/undoClipping issue #63

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
11 changes: 5 additions & 6 deletions src/prototype/dom/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -1356,15 +1356,14 @@
**/
function makeClipping(element) {
element = $(element);

var storage = Element.getStorage(element),
madeClipping = storage.get('prototype_made_clipping');

// The "prototype_made_clipping" storage key is meant to hold the
// original CSS overflow value. A string value or `null` means that we've
// original CSS overflow value. A string value (even empty) means that we've
// called `makeClipping` already. An `undefined` value means we haven't.
if (Object.isUndefined(madeClipping)) {
var overflow = Element.getStyle(element, 'overflow');
if (Object.isString(madeClipping)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be if (!Object.isString(madeClipping))? If it's a string, it means we've already made this element clip, and so we're doing extra work for no reason.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, do you need to change these conditionals at all? I might be missing something, but won't it suffice to do var overflow = element.style.overflow || '' like you did in the line below?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are absolutely correct, I've somehow missed negation in if (!Object.isString(madeClipping)).

And yes again, unchanged if (Object.isUndefined(madeClipping)) should work. I've made here isString() just for symmetry with check at line 1427: if (Object.isString(overflow)).

var overflow = element.style.overflow || '';
storage.set('prototype_made_clipping', overflow);
if (overflow !== 'hidden')
element.style.overflow = 'hidden';
Expand Down Expand Up @@ -1425,9 +1424,9 @@
var storage = Element.getStorage(element),
overflow = storage.get('prototype_made_clipping');

if (!Object.isUndefined(overflow)) {
if (Object.isString(overflow)) {
storage.unset('prototype_made_clipping');
element.style.overflow = overflow || '';
element.style.overflow = overflow;
}

return element;
Expand Down