Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use foldr instead of foldl and reverse in Html.Styled.Internal #331

Open
wants to merge 1 commit into
base: html-styled
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions src/Html/Styled/Internal.elm
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ unstyle elemType attributes children =
List.foldl accumulateStyles Dict.empty attributes

( childNodes, styles ) =
List.foldl accumulateInternalHtml
List.foldr accumulateInternalHtml
( [], initialStyles )
children

Expand All @@ -73,7 +73,7 @@ unstyle elemType attributes children =
properties =
List.map extractProperty attributes
in
VirtualDom.node elemType properties (styleNode :: List.reverse childNodes)
VirtualDom.node elemType properties (styleNode :: childNodes)


unstyleKeyed :
Expand All @@ -87,7 +87,7 @@ unstyleKeyed elemType attributes keyedChildren =
List.foldl accumulateStyles Dict.empty attributes

( keyedChildNodes, styles ) =
List.foldl accumulateKeyedInternalHtml
List.foldr accumulateKeyedInternalHtml
( [], initialStyles )
keyedChildren

Expand All @@ -97,7 +97,7 @@ unstyleKeyed elemType attributes keyedChildren =
properties =
List.map extractProperty attributes
in
VirtualDom.keyedNode elemType properties (keyedStyleNode :: List.reverse keyedChildNodes)
VirtualDom.keyedNode elemType properties (keyedStyleNode :: keyedChildNodes)



Expand Down Expand Up @@ -163,12 +163,12 @@ accumulateInternalHtml html ( nodes, styles ) =
List.foldl accumulateStyles styles attributes

( childNodes, finalStyles ) =
List.foldl accumulateInternalHtml ( [], combinedStyles ) children
List.foldr accumulateInternalHtml ( [], combinedStyles ) children

vdom =
VirtualDom.node elemType
(List.map extractProperty attributes)
(List.reverse childNodes)
childNodes
in
( vdom :: nodes, finalStyles )

Expand All @@ -178,12 +178,12 @@ accumulateInternalHtml html ( nodes, styles ) =
List.foldl accumulateStyles styles attributes

( childNodes, finalStyles ) =
List.foldl accumulateKeyedInternalHtml ( [], combinedStyles ) children
List.foldr accumulateKeyedInternalHtml ( [], combinedStyles ) children

vdom =
VirtualDom.keyedNode elemType
(List.map extractProperty attributes)
(List.reverse childNodes)
childNodes
in
( vdom :: nodes, finalStyles )

Expand All @@ -203,12 +203,12 @@ accumulateKeyedInternalHtml ( key, html ) ( pairs, styles ) =
List.foldl accumulateStyles styles attributes

( childNodes, finalStyles ) =
List.foldl accumulateInternalHtml ( [], combinedStyles ) children
List.foldr accumulateInternalHtml ( [], combinedStyles ) children

vdom =
VirtualDom.node elemType
(List.map extractProperty attributes)
(List.reverse childNodes)
childNodes
in
( ( key, vdom ) :: pairs, finalStyles )

Expand All @@ -218,12 +218,12 @@ accumulateKeyedInternalHtml ( key, html ) ( pairs, styles ) =
List.foldl accumulateStyles styles attributes

( childNodes, finalStyles ) =
List.foldl accumulateKeyedInternalHtml ( [], combinedStyles ) children
List.foldr accumulateKeyedInternalHtml ( [], combinedStyles ) children

vdom =
VirtualDom.keyedNode elemType
(List.map extractProperty attributes)
(List.reverse childNodes)
childNodes
in
( ( key, vdom ) :: pairs, finalStyles )

Expand Down