 		return ret
 	# attributes
 	getAttribute: (name) ->
-		@attributes[name] ? ""
+		@attributes[name] or ""
 	getAttributeNode: (name) ->
 		n = new Attr(name, @getAttribute(name))
 		n.ownerElement = @

	@_private.childIndex = -1
Node::__defineGetter__ 'firstChild', () -> @childNodes[0]
Node::__defineGetter__ 'lastChild', () -> @childNodes[-1]
Node::__defineGetter__ 'id', () -> @attributes['id']
Node::__defineSetter__ 'id', (value) ->
	o = @ownerDocument?
	if o
		if @attributes.id?
			delete @ownerDocument._private.idMap[@attributes.id]
	if value in [null, undefined, "undefined"]
		delete @attributes.id
	else
		if o
			@ownerDocument._private.idMap[value] = @
		@attributes.id = value
Node::__defineGetter__ 'className', () -> @attributes['class'] or ""
Node::__defineSetter__ 'className', (value) ->
	if value in [null, undefined, "undefined"]
		delete @attributes.class
		@_private.classes.length = 0
	else
		@attributes['class'] = value
		# Optimization for getElementsByClassName, cache the split form
		@_private.classes = value.split(' ')

class Entity extends Node
	constructor: (a...) ->

	g.Node = Node
	g.Document = Document
	g.DocumentFragment = DocumentFragment
	g.NodeList = Array # TODO: a real implementation of a (live?) NodeList
	g.Event = Event
	for tagName of ELEMENT_MAP
		c = ELEMENT_MAP[tagName]
		g[c.name] = c
