Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix for makeClipping/undoClipping issue #63

Open
wants to merge 1 commit into from

2 participants

@victor-homyakov

I've made earlier pull request with failing unit test for issue #1063 with Element#makeClipping()/Element#undoClipping(). Here is a patch for this issue. It deals with exact value of element.style, not with computed Element#getStyle().

@victor-homyakov victor-homyakov Fix for makeClipping/undoClipping issue
I've made earlier pull request with failing unit test for issue #1063 with `Element#makeClipping()`/`Element#undoClipping()`. Here is a patch for this issue. It deals with exact value of `element.style`, not with computed `Element#getStyle()`.
c5ee80d
@savetheclocktower savetheclocktower commented on the diff
src/prototype/dom/layout.js
((11 lines not shown))
// called `makeClipping` already. An `undefined` value means we haven't.
- if (Object.isUndefined(madeClipping)) {
- var overflow = Element.getStyle(element, 'overflow');
+ if (Object.isString(madeClipping)) {
@savetheclocktower Collaborator

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.

@savetheclocktower Collaborator

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?

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)).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 28, 2012
  1. @victor-homyakov

    Fix for makeClipping/undoClipping issue

    victor-homyakov authored
    I've made earlier pull request with failing unit test for issue #1063 with `Element#makeClipping()`/`Element#undoClipping()`. Here is a patch for this issue. It deals with exact value of `element.style`, not with computed `Element#getStyle()`.
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 6 deletions.
  1. +5 −6 src/prototype/dom/layout.js
View
11 src/prototype/dom/layout.js
@@ -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)) {
@savetheclocktower Collaborator

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.

@savetheclocktower Collaborator

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?

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)).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ var overflow = element.style.overflow || '';
storage.set('prototype_made_clipping', overflow);
if (overflow !== 'hidden')
element.style.overflow = 'hidden';
@@ -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;
Something went wrong with that request. Please try again.