fixed parent issue (only one parent per Y.Xml type)

This commit is contained in:
DadaMonad
2015-02-25 23:41:57 +00:00
parent 9059618d1f
commit 82f11c421f
11 changed files with 114 additions and 52 deletions

View File

@@ -70,7 +70,11 @@ module.exports = ()->
# TODO: Do something with timeouts. You don't want this to fire for every operation (e.g. insert).
# TODO: do you need callEvent+forwardEvent? Only one suffices probably
callEvent: ()->
@forwardEvent @, arguments...
if @custom_type?
callon = @getCustomType()
else
callon = @
@forwardEvent callon, arguments...
#
# Fire an event and specify in which context the listener is called (set 'this').

View File

@@ -32,11 +32,21 @@ class YXml
@_model.val("children", new Y.List())
if @_xml.parent?
@_model.val("parent", @_xml.parent)
delete @_xml
@_setModel @_model
@_model
_setModel: (@_model)->
delete @_xml
@_model.observe (events)->
for event in events
if event.name is "parent" and event.type isnt "add"
parent = event.oldValue
for c,i in parent.getChildren()
if c is @
parent._model.val("children").delete i
break
undefined
_setParent: (parent)->
if parent instanceof YXml
@@ -188,13 +198,8 @@ class YXml
# .remove()
#
remove: ()->
parent = @_model.val("parent")
if parent instanceof YXml
for c,i in parent.getChildren()
if c is @
parent._model.val("children").delete i
break
undefined
parent = @_model.delete("parent")
@
#
# Remove an attribute from this element