Comments (7)
> var f=base2.JSON.String.toJSONString;
> f.call(base2.JSON.String, "I said no!") == "I said no!"
> this.escape("I said no") == "I%20said%20no%21"
This is a coincidence really. Normally when you detach a JavaScript method it
doesn't
work at all. This works in a strange way because JSON.String and the global
object
both define an escape() method.
On a general note, and to answer your second question, Modules are static
objects
that just happen to be classes. All methods are static! That is why "this"
works for
static members. The prototype is built by delegating object methods to their
equivalent static method. That way, modules can act as mixins too.
See this for an example:
http://base2.googlecode.com/svn/trunk/src/base2/Module.txt
> BTW: can you create a "Type-Inquiry"
Will do. I'll also create Type-Discussion.
Original comment by [email protected]
on 27 Jul 2007 at 9:19
from base2.
I realized the coincidence.
I know how I can use Modules. I just haven't looked at the inner workings. Or
better: I opened the file, and 3
seconds later closed it again. I might open the file again, some other time ;-)
But, if you do:
var addClass=base2.DOM.HTMLElement.addClass;
addClass(document.body, "bold");
you get this error:
Value undefined (result of expression this.hasClass) is not object.
I just think some people are going to make this mistake, and will look in the
wrong places to solve this. Eventually,
they will see their mistake (and realize mixins are cool), or for the worse:
work around the mistake (and never
realize mixins are subzero). Either way: there's some cognitive disonance.
With other words: can we "fix" this non-technical usability error easy?
Original comment by [email protected]
on 27 Jul 2007 at 9:51
- Changed state: Started
- Added labels: Type-Discuss
- Removed labels: Type-Inquiry
from base2.
Are you saying that people will expect Module methods to be detachable like
this?
Original comment by [email protected]
on 27 Jul 2007 at 10:26
from base2.
In a way, I guess. Like I now know what I can do with Module doesn't mean I
fathom the complete concept. When I
encountered the issue, I didn't even realize base2.JSON.String *was* a Module.
And I also can imagine, people will not grasp the concept of Module enough, to
withhold them making this mistake
(made up innermind conversation of some developer: "hey, modules, cool. You can
apply them to classes, and use 'm
standalone. That's a lot of syntax. Let's create a shortcut variable"...).
But for my sake they don't need to be used detached. Can't we add some checks,
so an meaningful exception is thrown
when a module-method is used detached?
Original comment by [email protected]
on 27 Jul 2007 at 10:38
from base2.
You know that all of base2.DOM is written as Modules? That's why you can do
this:
HTMLElement.addClass(element, "cool"); // as module
or:
HTMLElement(element); // as mixin
element.addClass("cooler");
you can also do this of course:
HTMLElement(element).addClass("cooler");
I'm not sure what to do about detaching Module methods. It would be a nice
feature. I
need to think about it for a bit...
Original comment by [email protected]
on 27 Jul 2007 at 10:57
from base2.
If you can address the issue with not too much trouble, it would be great.
The bigger issue is I think addressing layer leakage. Base2 adds new concepts
on top of javascript. But once and a
while, some javascript things leak though. We need to keep the leakage as low
as possible, and when inevitable,
provide a towel (a meaningful exception, documentation).
Original comment by [email protected]
on 27 Jul 2007 at 11:10
from base2.
I'm closing this issue (the original bug was fixed long ago).
As to detachable module methods, raise another issue for this if you think it is
important.
Original comment by [email protected]
on 10 Aug 2007 at 4:21
- Changed state: Fixed
from base2.
Related Issues (20)
- Please add Array2.make HOT 2
- 'Unspecified error' when loading a page via iframe in IE8.
- Function.bind() defined in Firefox 4 conflicts with Base2's own bind()s. HOT 1
- base62 encoding shrinked script fails with 3.1 but works with 3.0 HOT 3
- Contact to the owner of the project? HOT 1
- DOMContentLoaded does not fire in Safari 3.0.4 (and possibly other versions) HOT 1
- IE throws "Unspecified Error" when calling some methods or accessing some properties of elements not attached to a document
- base2.jsb.eventDispatcher fails to dispatch (delegated?) events under IE9
- Listeners for (before)?(cut|copy|paste) events are not executed in IE7-9 HOT 1
- Patch for /trunk/src/apps/MiniWeb/Client.js
- Patch for /trunk/src/apps/MiniWeb/Client.js
- document not geting extended.
- getting opacity in getComputedPropertyValue of ViewCSS returns empty string on element without opacity set
- Eclipse "Syntax error on token "new", ArrayLiteralHeader expected after this token", l. 19 of v1.0.2 of base2.js HOT 3
- Consider relying on HTML ClassList API
- :checked pseudo-class doesn't match selected option elements.
- Non ascii strings broken when encoded HOT 1
- classList.remove can incorrectly trigger IE's onpropertychange event.
- Allow Base cast specialization HOT 1
- Patch for /trunk/src/apps/packer/Base62.js HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from base2.