Skip to content

Commit

Permalink
Fixes #404. Mispelling of detach
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonyjb committed Apr 24, 2017
1 parent 9c79df4 commit caf8599
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 23 deletions.
16 changes: 13 additions & 3 deletions build/content-tools.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/content-tools.min.css

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions build/content-tools.min.js

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions spec/content-tools-spec.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 20 additions & 2 deletions src/scripts/ui/ui.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class ContentTools.ComponentUI
return
ContentEdit.addCSSClass(@_domElement, className)

detatch: (component) ->
detach: (component) ->
# Detach a child component from this component

# Find the component to detatch (if not found return)
Expand All @@ -67,6 +67,15 @@ class ContentTools.ComponentUI
# Remove the component from the components children
@_children.splice(componentIndex, 1)

detatch: (component) ->
# Misspelling present in earlier versions, retain until the next minor
# release so that a patch can be provided without breaking backward
# compatability.
console.log(
'Please call detach, detatch will be removed in release 1.4.x'
)
@detach(component)

mount: () ->
# Mount the component to the DOM

Expand Down Expand Up @@ -190,13 +199,22 @@ class ContentTools.WidgetUI extends ContentTools.ComponentUI
if not @isMounted()
component.mount()

detatch: (component) ->
detach: (component) ->
# Detach a child component from this component
super(component)

if @isMounted()
component.unmount()

detatch: (component) ->
# Misspelling present in earlier versions, retain until the next minor
# release so that a patch can be provided without breaking backward
# compatability.
console.log(
'Please call detach, detatch will be removed in release 1.4.x'
)
@detach(component)

show: () ->
# Show the widget

Expand Down
12 changes: 6 additions & 6 deletions src/spec/ui/ui.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,14 @@ describe 'ContentTools.ComponentUI.addCSSClass()', () ->
expect(domElement.getAttribute('class')).toBe 'foo'


describe 'ContentTools.ComponentUI.detatch()', () ->
describe 'ContentTools.ComponentUI.detach()', () ->

it 'should detatch a child component', () ->
it 'should detach a child component', () ->

parent = new ContentTools.ComponentUI()
child = new ContentTools.ComponentUI()
parent.attach(child)
parent.detatch(child)
parent.detach(child)

expect(parent.children()).toEqual []

Expand Down Expand Up @@ -388,9 +388,9 @@ describe 'ContentTools.WidgetUI.attach()', () ->
expect(child.mount).toHaveBeenCalledWith()


describe 'ContentTools.WidgetUI.detatch()', () ->
describe 'ContentTools.WidgetUI.detach()', () ->

it 'should detatch a child widget and unmount it', () ->
fit 'should detach a child widget and unmount it', () ->

parent = new ContentTools.WidgetUI()
child = new ContentTools.WidgetUI()
Expand All @@ -402,7 +402,7 @@ describe 'ContentTools.WidgetUI.detatch()', () ->
domElement = document.createElement('div')
document.body.appendChild(domElement)
parent._domElement = domElement
parent.detatch(child)
parent.detach(child)

# Check the widget was removed as a child
expect(parent.children()).toEqual []
Expand Down

0 comments on commit caf8599

Please sign in to comment.