- # FIXME read implement "foster parenting" part
- # FIXME read spec, do this right
- # FIXME implement the override target thing
- # note: this assumes it's an open tag
- # FIXME what part of the spec is this?
- # TODO look through all callers of this, and see what they should really be doing.
- # eg probably insert_html_element for tokens
- tree_insert_element = (el, override_target = null, namespace = null) ->
- if namespace?
- el.namespace = namespace
- dest = adjusted_insertion_location override_target
- if el.type is TYPE_START_TAG # means it's a "token"
- el = token_to_element el, namespace, dest[0]
- unless el.namespace?
- namespace = dest.namespace
- # fixfull: Document nodes sometimes can't accept more chidren
- dest[0].children.splice dest[1], 0, el
- el.parent = dest[0]
- open_els.unshift el
- return el
-