From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-we0-x229.google.com (mail-we0-x229.google.com [IPv6:2a00:1450:400c:c03::229]) by hurricane.the-brannons.com (Postfix) with ESMTPS id 6934C78F08 for ; Tue, 13 Jan 2015 16:18:25 -0800 (PST) Received: by mail-we0-f169.google.com with SMTP id m14so5950448wev.0 for ; Tue, 13 Jan 2015 16:15:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=VUzTU4qoPKokqy5BB5SXKFMzoyHb1H0/5NZTFmhYv2Y=; b=SnnwL+9IWCLM2iYgxU97W19RI/A2dLjCOmL8DmFIqtL142C+DlJblsYvEs+iQnWXS1 NnyUS43Cq+9aUDH/vQOWVY49ezXhdD9K8vpygSfXQNWPRqGuOW/821WrSHp6aYOhhbzi 1qKAzRnHHAZuhvkGnvwnZP1EByX3hygy5VZw57e778s0xlX1ZMvr43orqHCUc7kmRqar lzb86ROh5AvG1/5DyhJp4fcJMFGGSqjjp1YEeMeyqaBvMOh0f3OEDnblQzelWtSblRry JNFnCa4fxG+48Qi5FOXCqz0T4KZZp6s18XS/HWf3wxWkdWgkwUFmQ22UFiDsQlFDOSLZ q9kg== X-Received: by 10.180.198.52 with SMTP id iz20mr45483684wic.60.1421194547594; Tue, 13 Jan 2015 16:15:47 -0800 (PST) Received: from toaster.adamthompson.me.uk (toaster.adamthompson.me.uk. [2001:8b0:1142:9042::2]) by mx.google.com with ESMTPSA id ei5sm16296983wid.2.2015.01.13.16.15.46 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Jan 2015 16:15:46 -0800 (PST) Date: Wed, 14 Jan 2015 00:15:38 +0000 From: Adam Thompson To: Karl Dahlke Message-ID: <20150114001538.GA24669@toaster.adamthompson.me.uk> References: <20150013184229.eklhad@comcast.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="PNTmBPCT7hxwcZjr" Content-Disposition: inline In-Reply-To: <20150013184229.eklhad@comcast.net> User-Agent: Mutt/1.5.23 (2014-03-12) Cc: Edbrowse-dev@lists.the-brannons.com Subject: Re: [Edbrowse-dev] startwindow.js changes X-BeenThere: edbrowse-dev@lists.the-brannons.com X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Edbrowse Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Jan 2015 00:18:26 -0000 --PNTmBPCT7hxwcZjr Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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, >=20 > 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. >
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 javascrt= ip, > 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 refere= nce but also javascript examples, including non-standard extensions and some no= tes 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 cor= rect 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:
first div
second div
third div
And use javascript to add a div saying "test div" between the 2nd and 3rd d= ivs, 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. --PNTmBPCT7hxwcZjr Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJUtbUqAAoJELZ22lNQBzHO4b0IAJ+JX13iGdqFn2OREVadRY8Y l1eYvyvDREeNzJjDjUuxnPMEjiNYO6707/GDQ8I8LNjlVzNbIKku+/Lc52+XWGUs UG+I0q6P/a+O05hbsZzQhfL3MfE7AMF4cM4FRkK/GKKwjKVM7zKKmHT8e0a7ZJ6u Nl/JKs5f8lrmirpn0rVDHAj6wv+scXCr1g3oL4+a2hk8KPmtsKcHacg643PWAdGn vq5/FOP40Ja7KFYzVYDJqG9dIMBsWtfGHDPLSAq+hPy+ZECmaTne32d09ScrxJ4Z Iqxnl6FRPjrkdBKsklAmy1tMNbJQyHqrz1V6zJiRK+N2OGRlsfU/73zR+rYitRE= =kgjr -----END PGP SIGNATURE----- --PNTmBPCT7hxwcZjr--