You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At present, Quixote fails fast when you make a "nonsense" comparison. For example, if you compare the width of an element to its top edge:
element.assert({width: element.top});
You will get the following exception:
Can't compare width of '#element' to top edge of '#element': Size isn't compatible with Position.
This is a "fail fast" approach. The code is designed to throw an exception when the programmer makes a mistake. Comparing the size of an element to its position is assumed to be a mistake.
Under the covers, positions and sizes are both just pixel values. They can easily be compared. Would we be better off taking out the fail-fast code and allowing the programmer to make "nonsense" comparisons? When would that be useful, and why? What are the tradeoffs?
Discuss this question here.
The text was updated successfully, but these errors were encountered:
I can see this being extremely useful. For some of our higher profile clients at the agency I work for, we have some pretty intricate style guides that must be followed. For instance, a logo who's left and right margin should be equal to double its top and bottom offset and 1/4 the width of the logo.
Thanks for the feedback. For the example you gave, what do you mean by top and bottom offset? Is it the distance from the logo to the containing element?
We don't have support for margins in yet, but in this case, I'm imagining the assertion might look something like this. I'm assuming the top and bottom offsets are the distance between the edge of the logo and the edge of a containing 'navbar' element:
// Hypotheticallogo.assert({marginLeftWidth: [// array is hypothetical; it means all conditions must be satisfiedlogo.width.times(1/4),// 1/4 width of logo; this exists todaylogo.top.distanceTo(navbar.top).times(2),// double the top offset (hypothetical)logo.bottom.distanceTo(navbar.bottom).times(2)// double the bottom offset (hypothetical)],marginRightWidth: logo.marginLeftWidth// the right margin has to equal the left margin});
At present, Quixote fails fast when you make a "nonsense" comparison. For example, if you compare the width of an element to its top edge:
You will get the following exception:
This is a "fail fast" approach. The code is designed to throw an exception when the programmer makes a mistake. Comparing the size of an element to its position is assumed to be a mistake.
Under the covers, positions and sizes are both just pixel values. They can easily be compared. Would we be better off taking out the fail-fast code and allowing the programmer to make "nonsense" comparisons? When would that be useful, and why? What are the tradeoffs?
Discuss this question here.
The text was updated successfully, but these errors were encountered: