Forgot the polyfills for IE. Just put them online:
https://github.com/xavierm02/XJSAccessors/commit/4915b5b1bdeb7b3f2f79f237ddf093cdfcd69af3

On Tue, Aug 30, 2011 at 10:29 PM, Xavier MONTILLET
<[email protected]> wrote:
> // Error (no support for rangeCount)
> That's because I only tested in Chrome and apparently, in Firefox,
> they have put 0 as rangeCount in the prototype so that a selection
> with no range doesn't need its own rangeCount property... Anyway now
> it does work.
> https://github.com/xavierm02/XJSAccessors/commit/b6779a387c0ac78ac30483de9ef2ffa48753f696
>
> I just added another thing to XJSAccessors:
> https://github.com/xavierm02/XJSAccessors/commit/55169a33125882b1b57b55fae87d597cee971447
> It lets you make the storage inherit from the object you like.
> And I just used it in XJSSelection:
> https://github.com/xavierm02/XJSAccessors/commit/b4a5135ec7b8323fdc3a32a472f7b05eb8e40a9a
> I also updated to get it to work in IE:
> https://github.com/xavierm02/XJSAccessors/commit/bb6d9578d7192b63ca83cc2b104d1b21273a15c8
> Now what happens is this:
> - The script looks if a selection has a rangeCount attribute and if it
> does does nothing
> - If it doesn't, is adds a getter for it
>
> And this is the whole point of those getters and setters: Some
> properties need to be calculated, others don't.
> When you use an object, do you want to have to remember which one is
> calculates and which one isn't? Certainly not (because you're a good
> guy and you cache it in a local variable anyway).
> You don't want to remember is it is selection.rangeCount or
> selection.getRangeCount(). You just have a simple syntax, the same for
> all properties, calculated of "static": selection.get( 'rangeCount' ).
>
> You'll tell me there is the solution of keeping only
> selection.getRangeCount( ) but then, you can't use for in and if you
> ever need a dynamic name selection[ name ], you'll have to handle
> putting it uppercase...
>
> Thanks for you interest btw :)
>
> -----------------------------------------------------------------
>
> Future plans:
> - Allow sharing the getters, setters and others objects (except
> storage) so that they are created only once if a class (~ Constructor)
> uses them several times (e.g. XJSSelection)
> - Allow binding certains properties to properties of others objects.
> This would be used in XJSSelection by removing the inheritance of
> selection by storage but just binding rangeCount. This way, you
> wouldn't be able to access browser specific properties of the
> selection.
>
>
> On Tue, Aug 30, 2011 at 9:10 PM, Scott Sauyet <[email protected]> wrote:
>> Xavier MONTILLET wrote:
>>> Xavier MONTILLET wrote:
>>>> Here is the code on Github:
>>>> https://github.com/xavierm02/XJSAccessors/blob/master/XJSAccessors.js
>>> And here is a usecase:
>>> https://github.com/xavierm02/XJSAccessors/blob/master/XJSSelection.js
>>
>> Maybe I'm simply missing the point, but I'm not convinced.  It seems
>> to me that you are using XJSAccessors in order to help build this API
>> for XJSSelection:
>>
>>    Chrome:
>>    =======
>>    var x = new XJSSelection();
>>    x.get('selection');             // DOMSelection {...}
>>    x.get('range', 0);              // XJSRange {...}
>>    x.get('range', 0).get('range'); // Range {...}
>>    x.get('rangeCount');            // 1
>>
>>    FF:
>>    ===
>>    var x = new XJSSelection();
>>    x.get('selection');   // Selection {...}
>>    x.get('range', 0);    // Error (no support for rangeCount)
>>    x.get('rangeCount');  // Error (no support for rangeCount)
>>
>> But that API seems much more complicated than this:
>>
>>    Chrome:
>>    =======
>>    var x = new XJSSelection();
>>    x.getSelection();             // DOMSelection {...}
>>    x.getRange(0);                // Range {...}
>>    x.getRangeCount();            // 1
>>
>>    FF:
>>    ===
>>    var x = new XJSSelection();
>>    x.getSelection();   // Selection {...}
>>    x.getRange(0);      // Error (no support for rangeCount)
>>    x.getRangeCount();  // Error (no support for rangeCount)
>>
>> And the code that uses these accessors is more complicated than the
>> code that doesn't use them, at least in my simple-minded test:
>>
>>    Original: http://scott.sauyet.com/Javascript/Test/2011-08-30a/
>>    Reworked: http://scott.sauyet.com/Javascript/Test/2011-08-30c/
>>
>> In either of these, you can load the page, select a range, and enter
>> `test()` in the console.
>>
>> The reworked version seems to provide the same facilities without
>> exposing any unwanted implementation details, using shorter, cleaner
>> code.  That's why I haven't yet seen the benefits of your accessors.
>> What am I missing?
>>
>>  -- Scott
>>
>>
>> --
>> To view archived discussions from the original JSMentors Mailman list: 
>> http://www.mail-archive.com/[email protected]/
>>
>> To search via a non-Google archive, visit here: 
>> http://www.mail-archive.com/[email protected]/
>>
>> To unsubscribe from this group, send email to
>> [email protected]
>>
>

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/[email protected]/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/[email protected]/

To unsubscribe from this group, send email to
[email protected]

Reply via email to