On Sat, 19 Aug 2017, Karl Dahlke wrote:

Not sure what querySelectorAll is all about; can't we just call 
document.getElementsByTagName()?

It's a thing of its own. A lot of sites' JS uses this. For instance, in the nasa.gov code file vendor.js,

e.querySelectorAll("[msallowcapture^='']")
e.querySelectorAll("[selected]")
e.querySelectorAll(":checked")
a=r.querySelector("#morph-"+n)
e.querySelectorAll("[id~="+q+"-]")
e.querySelectorAll("a#"+q+"+*")

The brackets, the hash and the colon have hardcoded meanings. And the syntax used here, I believe is the same selector syntax you find in CSS blocks. So at the least, there's also the period and the at symbol:

  .hidden { visibility: hidden; }
  @font-face { font-family: "AcidAhemTest"; src: url(font.ttf); }


So if an object says p.snork has bgcolor=white
then we get the array
a = document.getElementsByTagName("p");
Loop over array and if obj.class == "snork" then obj.style.bgcolor = white.
Or if the descriptor is on #instructions rather than a class of nodes, we use 
getElementById to find the node and then set its values.
So I think we already have the middle third, and the last third seems 
reasonably easy to write.

I don't rule out that this can be done. It depends if you want to dig in to the selectors language-within-a-language or use a component to hopefully avoid having to. If it's fun, that's good. If it's completely undesirable to learn a new mini syntax, maybe the outside component can do it for us.

I think even if you wanted to do a certain thing within the implementation that called getElements, there would need to be a wrapper called querySel etc which is going to receive an argument beginning with a symbol. We can any kind of node math we want under the hood in order to select the results.

It's definitely possible that you will know how to do it, so that it would turn out to be less work than bringing in the outside code. I don't know which of those is less work.

Kevin

_______________________________________________
Edbrowse-dev mailing list
[email protected]
http://lists.the-brannons.com/mailman/listinfo/edbrowse-dev

Reply via email to