Skip to content

Commit

Permalink
Merge pull request #120 from ba-st/fix-scrollIntoView
Browse files Browse the repository at this point in the history
Forced ScrollIntoViewCommand to dereference the iterated items before…
  • Loading branch information
gcotelli authored May 23, 2018
2 parents b02e584 + 61ee37c commit ce4c844
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion source/Willow-Tests/ScrollIntoViewCommandTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ ScrollIntoViewCommandTest >> testModelLoadingActions [

self
assert: html
equals: '<a id="id1"></a><script type="text/javascript">$("#id1").click(function(){$("#id8").each(function(){$(this).scrollIntoView()})});</script>'
equals: '<a id="id1"></a><script type="text/javascript">$("#id1").click(function(){$("#id8").each(function(){$(this).get(0).scrollIntoView()})});</script>'
]

{ #category : #'tests-accessing' }
Expand Down
10 changes: 7 additions & 3 deletions source/Willow/ScrollIntoViewCommand.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ ScrollIntoViewCommand >> clientIndependentActions [
^#()
]

{ #category : #'accessing - private' }
{ #category : #'private - accessing' }
ScrollIntoViewCommand >> identifierToShow [

^identifierProvider value
]

{ #category : #'initialize-release' }
{ #category : #initialization }
ScrollIntoViewCommand >> initializeWithComponentIdentifierProvidedBy: anIdentifierProvider [

identifierProvider := anIdentifierProvider
Expand All @@ -38,8 +38,12 @@ ScrollIntoViewCommand >> initializeWithComponentIdentifierProvidedBy: anIdentifi
{ #category : #accessing }
ScrollIntoViewCommand >> modelLoadingActions [

"We iterate the result before sending the scrolling message in case no match is found."

^ Array
with: [ :aScript :aCanvas | aScript << (aCanvas jQuery id: self identifierToShow) each: (aCanvas jQuery this call: 'scrollIntoView') ]
with: [ :aScript :aCanvas |
aScript << (aCanvas jQuery id: self identifierToShow)
each: ((aCanvas jQuery this get: 0) call: 'scrollIntoView') ]
]

{ #category : #accessing }
Expand Down

0 comments on commit ce4c844

Please sign in to comment.