It's an interesting idea but the notion of using a selector syntax as a creation syntax seems to break down rather quickly.
Where xpath is loose, you end up being strict. For example the sibling syntax creates two of something. But there's no syntax to make three. It might have been better just to leave that out.
Also, the syntax to remove something is truly bizarre; you put() the negation. Would it really be so bad to have another function, like remove() ?
Anyway I appreciate a totally different take on the problem here. A templated approach seems like a cool idea. jQuery can be a little wordy when creating structure, since their creation syntax simply is HTML, and if you want to make it dependent on other data or ensure that data is well escaped then you end up switching paradigms in the same line of code, e.g. $('<a>').attr( 'href', foo );
I think the 3x sibling would just be "td+td+td". I could be wrong about that though, I haven't tried it out. Might have to, I find it very interesting.
> It's an interesting idea but the notion of using a selector syntax as a creation syntax seems to break down rather quickly.
It's also unfriendly to (partially) generated or separately-configured names, leading to some kind of weird positional-only substitution system.
> Also, the syntax to remove something is truly bizarre; you put() the negation.
Not to mention it's not the actual negation: you add the class 'foo' with `.foo` but you remove it with `!foo` instead of `!.foo` (or even better, the perfectly standard `:not` negation pseudo-class: why not remove `.foo` with `:not(.foo)`?). This leads to a non-generic removal syntax: attribute removal has a different one (you negate the attribute name within the brackets), and ids apparently are not removable (via the #-syntax selector).
Neither can you remove a child from a parent I guess, not without getting a handle to the child element itself and writing `put(elementToDelete, "!");`.
I wrote something similar a while ago, mostly inspired by the various Zen Coding plugins. Nice to be able to compare my approach with someone who knows what they're doing.
[+] [-] neilk|14 years ago|reply
Where xpath is loose, you end up being strict. For example the sibling syntax creates two of something. But there's no syntax to make three. It might have been better just to leave that out.
Also, the syntax to remove something is truly bizarre; you put() the negation. Would it really be so bad to have another function, like remove() ?
Anyway I appreciate a totally different take on the problem here. A templated approach seems like a cool idea. jQuery can be a little wordy when creating structure, since their creation syntax simply is HTML, and if you want to make it dependent on other data or ensure that data is well escaped then you end up switching paradigms in the same line of code, e.g. $('<a>').attr( 'href', foo );
[+] [-] Groxx|14 years ago|reply
[+] [-] masklinn|14 years ago|reply
It's also unfriendly to (partially) generated or separately-configured names, leading to some kind of weird positional-only substitution system.
> Also, the syntax to remove something is truly bizarre; you put() the negation.
Not to mention it's not the actual negation: you add the class 'foo' with `.foo` but you remove it with `!foo` instead of `!.foo` (or even better, the perfectly standard `:not` negation pseudo-class: why not remove `.foo` with `:not(.foo)`?). This leads to a non-generic removal syntax: attribute removal has a different one (you negate the attribute name within the brackets), and ids apparently are not removable (via the #-syntax selector).
Neither can you remove a child from a parent I guess, not without getting a handle to the child element itself and writing `put(elementToDelete, "!");`.
[+] [-] brian_c|14 years ago|reply
You can play with mine here: http://viewinglens.com/dojo-modules/brian.util.create.html
And the source: https://github.com/brian-c/dojo-modules/blob/master/brian/ut...
[+] [-] anm8tr|14 years ago|reply