Add Buffer.findMarker[s], which returns marker[s] matching attributes

This commit is contained in:
Nathan Sobo
2013-04-24 17:10:20 -06:00
parent df6feab346
commit 0f0480b79f
3 changed files with 45 additions and 3 deletions

View File

@@ -13,7 +13,7 @@ class BufferMarker
###
# Internal #
###
constructor: ({@id, @buffer, range, @invalidationStrategy, noTail, reverse}) ->
constructor: ({@id, @buffer, range, @invalidationStrategy, @attributes, noTail, reverse}) ->
@invalidationStrategy ?= 'contains'
@setRange(range, {noTail, reverse})
@@ -45,6 +45,14 @@ class BufferMarker
isReversed: ->
@tailPosition? and @headPosition.isLessThan(@tailPosition)
# Checks that the marker's attributes match the given attributes
#
# Returns a {Boolean}.
matchesAttributes: (queryAttributes) ->
for key, value of queryAttributes
return false unless _.isEqual(@attributes[key], value)
true
# Public: Identifies if the marker's head position is equal to its tail.
#
# Returns a {Boolean}.