Re: childElements, childElementCount, and children (was: [ElementTraversal]: Feature string for DOMImplementation.hasFeature(feature, version)?)
@deprecated ? :) On Tue, Oct 20, 2009 at 8:22 PM, Robert O'Callahan rob...@ocallahan.org wrote: On Wed, Oct 21, 2009 at 4:15 PM, Maciej Stachowiak m...@apple.com wrote: I agree. The reason I phrased it as I did was to contrast with my previous remarks. The children attribute should be part of a standard, even though it creates what I think is a poor design pattern (mix of previous/next and indexed access to the same collection). It might be worth adding annotations to the spec to say this API is terrible, do not use and this API is terrible, do not follow its design. Rob -- He was pierced for our transgressions, he was crushed for our iniquities; the punishment that brought us peace was upon him, and by his wounds we are healed. We all, like sheep, have gone astray, each of us has turned to his own way; and the LORD has laid on him the iniquity of us all. [Isaiah 53:5-6]
Re: childElements, childElementCount, and children (was: [ElementTraversal]: Feature string for DOMImplementation.hasFeature(feature, version)?)
In this particular case, I think anything that's implemented in all of the major browser engines should be an official standard, not just de facto. Why only in this particular case? :) As a rule that seems like sound guidance. If it's implemented everywhere, shouldn't you have to make a pretty compelling case for it _not_ to be included in an official standard? On Tue, Oct 20, 2009 at 1:42 PM, Maciej Stachowiak m...@apple.com wrote: On Oct 18, 2009, at 4:14 AM, Jonas Sicking wrote: On Sun, Oct 18, 2009 at 12:12 AM, Doug Schepers schep...@w3.org wrote: So, rather than dwell on an admittedly imperfect spec, I personally suggest that we urge WebKit developers to implement .children and .children.length, in the anticipation that this will be in a future spec but can be useful to authors today. They already do. Which casts some amount of doubt on Maciejs argument that it was too performance heavy to implement in WebKit. :) What I said way back in the day (about childElements) was this: I suggest leaving this out, because it's not possible to implement both next/previous and indexed access in a way that is efficient for all cases (it's possible to make it fast for most cases but pretty challenging to make it efficient for all). This is especially bad with a live list and an element whose contents may be changing while you are iterating. If all you care about is looping through once, writing the loop with nextElementSibling is not significantly harder than indexing a list. I stand by that remark. It is indeed hard to get both indexed and previous/next access efficient in all cases. Of course, we are not going to let that stop us from interoperating with de facto standards, and we do our best (as for other kinds of NodeLists and HTMLCollections), but I'd rather not have new APIs follow this pattern. In this particular case, I think anything that's implemented in all of the major browser engines should be an official standard, not just de facto. Regards, Maciej
Re: childElements, childElementCount, and children (was: [ElementTraversal]: Feature string for DOMImplementation.hasFeature(feature, version)?)
On Oct 18, 2009, at 4:14 AM, Jonas Sicking wrote: On Sun, Oct 18, 2009 at 12:12 AM, Doug Schepers schep...@w3.org wrote: So, rather than dwell on an admittedly imperfect spec, I personally suggest that we urge WebKit developers to implement .children and .children.length, in the anticipation that this will be in a future spec but can be useful to authors today. They already do. Which casts some amount of doubt on Maciejs argument that it was too performance heavy to implement in WebKit. :) What I said way back in the day (about childElements) was this: I suggest leaving this out, because it's not possible to implement both next/previous and indexed access in a way that is efficient for all cases (it's possible to make it fast for most cases but pretty challenging to make it efficient for all). This is especially bad with a live list and an element whose contents may be changing while you are iterating. If all you care about is looping through once, writing the loop with nextElementSibling is not significantly harder than indexing a list. I stand by that remark. It is indeed hard to get both indexed and previous/next access efficient in all cases. Of course, we are not going to let that stop us from interoperating with de facto standards, and we do our best (as for other kinds of NodeLists and HTMLCollections), but I'd rather not have new APIs follow this pattern. In this particular case, I think anything that's implemented in all of the major browser engines should be an official standard, not just de facto. Regards, Maciej
Re: childElements, childElementCount, and children (was: [ElementTraversal]: Feature string for DOMImplementation.hasFeature(feature, version)?)
On Wed, Oct 21, 2009 at 4:15 PM, Maciej Stachowiak m...@apple.com wrote: I agree. The reason I phrased it as I did was to contrast with my previous remarks. The children attribute should be part of a standard, even though it creates what I think is a poor design pattern (mix of previous/next and indexed access to the same collection). It might be worth adding annotations to the spec to say this API is terrible, do not use and this API is terrible, do not follow its design. Rob -- He was pierced for our transgressions, he was crushed for our iniquities; the punishment that brought us peace was upon him, and by his wounds we are healed. We all, like sheep, have gone astray, each of us has turned to his own way; and the LORD has laid on him the iniquity of us all. [Isaiah 53:5-6]
Re: childElements, childElementCount, and children (was: [ElementTraversal]: Feature string for DOMImplementation.hasFeature(feature, version)?)
On Oct 20, 2009, at 8:22 PM, Robert O'Callahan wrote: On Wed, Oct 21, 2009 at 4:15 PM, Maciej Stachowiak m...@apple.com wrote: I agree. The reason I phrased it as I did was to contrast with my previous remarks. The children attribute should be part of a standard, even though it creates what I think is a poor design pattern (mix of previous/next and indexed access to the same collection). It might be worth adding annotations to the spec to say this API is terrible, do not use and this API is terrible, do not follow its design. Are there any DOM Core methods where those notes would not apply? :-) - Maciej
Re: childElements, childElementCount, and children (was: [ElementTraversal]: Feature string for DOMImplementation.hasFeature(feature, version)?)
On Sun, Oct 18, 2009 at 12:12 AM, Doug Schepers schep...@w3.org wrote: So, rather than dwell on an admittedly imperfect spec, I personally suggest that we urge WebKit developers to implement .children and .children.length, in the anticipation that this will be in a future spec but can be useful to authors today. They already do. Which casts some amount of doubt on Maciejs argument that it was too performance heavy to implement in WebKit. :) / Jonas p.s. It also works in Opera and IE.