Builder.subview wires an outlet directly, rather than assigning an outlet property.

This commit is contained in:
Corey Johnson & Nathan Sobo
2011-12-29 13:10:44 -06:00
parent b25fc80c9a
commit 0285c3d94d
2 changed files with 6 additions and 2 deletions

View File

@@ -50,6 +50,9 @@ describe "Builder", ->
@h2 params.title
@div "I am a subview"
viewProperties:
foo: "bar"
it "inserts a view built from the given template with the given params", ->
builder.tag 'div', ->
builder.tag 'h1', "Superview"
@@ -58,6 +61,7 @@ describe "Builder", ->
fragment = builder.toFragment()
expect(fragment.find("h1:contains(Superview)")).toExist()
expect(fragment.find("h2:contains(Subview)")).toExist()
subview = fragment.find('div[outlet=sub]')
subview = fragment.sub
expect(subview).toMatchSelector ':has(h2):contains(I am a subview)'
expect(subview.foo).toBe 'bar'

View File

@@ -45,7 +45,7 @@ class Builder
subviewId = _.uniqueId('subview')
@tag 'div', id: subviewId
@postProcessingFns.push (view) ->
subview.attr('outlet', outletName)
view[outletName] = subview
view.find("div##{subviewId}").replaceWith(subview)
elementIsVoid: (name) ->