[Seaside] JSObject printOn:
Stan Shepherd
stan.shepherd414 at gmail.com
Tue Dec 22 14:31:22 UTC 2009
Lukas Renggli wrote:
>
>> Shouldn't JSObject>>printOn: be something else, so printOn: can show
>> information in the inspector? And
>
> The use of #printOn: has legacy reasons.
>
>> addLoadScript: anObject
>> loadScripts := loadScripts copyWith: anObject.
>> ^ anObject
>>
>> could more meaningfully reference aJSObject ?
>
> Also it makes it possible to use any objects (like strings themselves)
> can be added as load scripts. Furthermore it avoids a naughty
> dependency: #addLoadScript: is in Seaside-Core, while JSObject is in
> an optional extra package.
>
>> As we rely on examples instead of documentation, these little things can
>> really impede 'getting' what a class is doing, IMHO.
>
> You are not the first one to complain about the (mis)use of #printOn:.
> Personally, I don't think it is too bad: it clearly communicates what
> the object is representing, a proxy for the Javascript representation
> it prints to.
>
> I agree that it would probably be better to change it to something like
>
> a JSObject(mock)
>
> where in brackets the Javascript representation is given.
> Unfortunately this is not easily possible given the wide application
> of this pattern in various internal and external Seaside Javascript
> libraries for over 4 years now.
>
> Lukas
>
>
Thanks for the explanation. I think we'll have to agree to disagree on
Lukas Renggli wrote:
>
> it clearly communicates what
> the object is representing, a proxy for the Javascript representation
> it prints to.
>
I suspect it clearly represents something when you have been using it for 4
years. ;)
Lukas Renggli wrote:
>
> Also it makes it possible to use any objects (like strings themselves)
> can be added as load scripts.
>
So would the following be a valid comment for #addLoadScript:?
addLoadScript: anObject
"anObject is any object which replies to #printOn: with valid javascript.
usually it will be a JSObject or a string.
example:
html document
addLoadScript: 'message()'.
will render:
<script type="text/javascript">/*<![CDATA[*/function
onLoad(){message()}/*]]>*/</script>"
loadScripts := loadScripts copyWith: anObject.
^ anObject
Cheers, ...Stan
--
View this message in context: http://n4.nabble.com/JSObject-printOn-tp976924p977004.html
Sent from the Squeak - Seaside mailing list archive at Nabble.com.
More information about the seaside
mailing list