Permalink
Browse files

Fixed a bug involving microevent not exporting doc.emit. Fixed closur…

…ed call to ._register()
  • Loading branch information...
1 parent 1e4ac38 commit 0450cc790d368574982b32ab362b4f5dd9da34e5 @josephg josephg committed Aug 15, 2011
View
@@ -153,7 +153,7 @@ Doc = (connection, @name, @version, @type, snapshot) ->
if @type['api']
this[k] = v for k, v of @type['api']
- @_register()
+ @['_register']?()
else
@provides = @['provides'] = {}
@@ -39,7 +39,7 @@ MicroEvent.mixin = (obj) ->
# Damn closure compiler :/
proto.on = proto['on'] = MicroEvent.prototype.on
proto.removeListener = proto['removeListener'] = MicroEvent.prototype.removeListener
- proto.emit = MicroEvent.prototype.emit
+ proto.emit = proto['emit'] = MicroEvent.prototype.emit
obj
module.exports = MicroEvent if module?.exports
View
@@ -2,40 +2,32 @@
text = require './text' if typeof WEB is 'undefined'
-text.api =
- provides: {'text':true}
+text['api'] =
+ 'provides': {'text':true}
# The number of characters in the string
- getLength: -> @snapshot.length
+ 'getLength': -> @snapshot.length
# Get the text contents of a document
- getText: -> @snapshot
+ 'getText': -> @snapshot
- insert: (text, pos, callback) ->
+ 'insert': (text, pos, callback) ->
pos = 0 unless pos?
op = [{'p':pos, 'i':text}]
@submitOp op, callback
op
- del: (length, pos, callback) ->
+ 'del': (length, pos, callback) ->
op = [{'p':pos, 'd':@snapshot[pos...(pos + length)]}]
@submitOp op, callback
op
- _register: ->
+ '_register': ->
@on 'remoteop', (op) ->
for component in op
if component['i'] != undefined
@emit 'insert', component['i'], component['p']
else
@emit 'delete', component['d'], component['p']
-
-# ... for closure. *sigh*
-text['api'] = text.api
-text.api['provides'] = text.api.provides
-text.api['getLength'] = text.api.getLength
-text.api['getText'] = text.api.getText
-text.api['insert'] = text.api.insert
-text.api['del'] = text.api.del
@@ -13,8 +13,8 @@ appendSkipChars = (op, doc, pos, maxlength) ->
maxlength -= part.length if maxlength != undefined and typeof part is 'string'
append op, (part.length || part)
-type.api =
- provides: {'text':true}
+type['api'] =
+ 'provides': {'text':true}
# The number of characters in the string
'getLength': -> @snapshot.charLength
@@ -56,7 +56,7 @@ type.api =
@submitOp op, callback
op
- _register: ->
+ '_register': ->
# Interpret recieved ops + generate more detailed events for them
@on 'remoteop', (op, snapshot) ->
textPos = 0
View
Oops, something went wrong.
Oops, something went wrong.
View
Oops, something went wrong.
Oops, something went wrong.

0 comments on commit 0450cc7

Please sign in to comment.