edbrowse-dev - development list for edbrowse
 help / color / mirror / Atom feed
From: Adam Thompson <arthompson1990@gmail.com>
To: Karl Dahlke <eklhad@comcast.net>
Cc: Edbrowse-dev@lists.the-brannons.com
Subject: Re: [Edbrowse-dev] startwindow.js changes
Date: Wed, 14 Jan 2015 00:15:38 +0000	[thread overview]
Message-ID: <20150114001538.GA24669@toaster.adamthompson.me.uk> (raw)
In-Reply-To: <20150013184229.eklhad@comcast.net>

[-- Attachment #1: Type: text/plain, Size: 2842 bytes --]

On Tue, Jan 13, 2015 at 06:42:29PM -0500, Karl Dahlke wrote:
> > the function returns the created element to javascript
> > which then inserts it into the DOM in the correct position,
> 
> Yes, but that's just part of it.
> Each tag/element is  put in the tree in its correct position,
> and also put in the list.
> It is linked in two places.
> That's how it works when produced by html.
> <form> creates a form object, which is somewhere in the dom tree,
> and *also* in the list of forms.
> I guessed, not much more than a guess, that that is how it works
> for elements created dynamically.
> An element e is placed somewhere in dom, as directed by javascrtip,
> and also put on the list of said elements,
> that part perhaps happening automatically.
> So I made the second part happen automatically, again being just a guess.
> Maybe the only way to know if my guess is right is to write some javascrtip,
> createElement,
> and alert document.list.length, and run it in a commercial browser

No, the w3c has a very complete DOM spec,
and if you look on w3schools.com you'll find not just a complete DOM reference
but also javascript examples, including non-standard extensions and some notes
on different browsers.
There's actually a *lot* of information on how this stuff *should* work and how
different browsers do things, no need for massive amounts of guess work if we
pick our resources correctly. Of course there'll be the odd browser-specific
thing we may think about incorperating,
but for the core DOM stuff and most of the stuff things like jquery expect,
there're standards and code examples.
I've even seen implementation notes and things about the guts of DOM.

As for inserting elements into lists,
when parsing html appending elements to the appropriate lists works because the
element's place in the DOM is dictated by the document.
However, in javascript, all document.createElement does is give you the correct
object, it doesn't link the element into the document in any way.
That's the job of the script creating the element.
For example if I have the following html:
<html>
<body>
<div>
first div
</div>
<div>
second div
</div>
<div>
third div
</div>
</body>
</html>

And use javascript to add a div saying "test div" between the 2nd and 3rd divs, then I'd expect it to appear at index 2 in document.divs as if it was created by html.
However, in our implementation it'd actually appear at index 3 in document.divs, but be at index 2 in the $kids$ array of the body node.
Also, from reading the w3schools DOM reference,
it appears that all DOM element nodes (i.e.
html, head, body, div etc) should inherit from Element,
and that we should have text nodes for text,
attribute nodes for tag attributes and even comment nodes for comments.

Cheers,
Adam.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

  reply	other threads:[~2015-01-14  0:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-13 23:42 Karl Dahlke
2015-01-14  0:15 ` Adam Thompson [this message]
  -- strict thread matches above, loose matches on Subject: below --
2015-01-13 21:10 Karl Dahlke
2015-01-13 23:21 ` Adam Thompson
2015-01-13 23:34   ` Adam Thompson
2015-01-13 20:38 Adam Thompson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150114001538.GA24669@toaster.adamthompson.me.uk \
    --to=arthompson1990@gmail.com \
    --cc=Edbrowse-dev@lists.the-brannons.com \
    --cc=eklhad@comcast.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).