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

markup: Multiple Class or ClassMap usage now appends additional classes #155

Merged
merged 1 commit into from
Oct 14, 2017

Conversation

pdf
Copy link
Contributor

@pdf pdf commented Oct 13, 2017

This enables component libraries and composition of elements with
classes.

BREAKING: The function prop.Class(string) has been removed and
replaced with vecty.Class(...string). Migrating users must use the
new function and split their classes into separate strings, rather than
a single space-separated string.

Fixes #80

@codecov-io
Copy link

codecov-io commented Oct 13, 2017

Codecov Report

Merging #155 into master will increase coverage by 3.91%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #155      +/-   ##
==========================================
+ Coverage   42.47%   46.38%   +3.91%     
==========================================
  Files           4        4              
  Lines         598      595       -3     
==========================================
+ Hits          254      276      +22     
+ Misses        312      287      -25     
  Partials       32       32
Impacted Files Coverage Δ
markup.go 70% <100%> (+23.84%) ⬆️
dom.go 42.2% <100%> (+0.92%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8b18b17...30de09c. Read the comment docs.

dom.go Outdated
// Classes
classList := h.node.Get("classList")
for name := range h.classes {
classList.Call("add", name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be good to assume the DOM API is slow than a map check, i.e. before calling add check prev:

if _, ok := prev.classes[name]; !ok {
    classList.Call("add", name)
}

But this is just a hunch / best practice in my mind. It's probably plenty fast so I am OK with this as-is if you don't wish to update.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably plenty fast, but I'm fine with the change as I haven't benchmarked.

markup.go Outdated
@@ -142,19 +142,36 @@ func Data(key, value string) Applyer {
})
}

// Class returns an Appyer which applies the provided classes. Subsequent
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo Appyer -> Applyer

@@ -229,33 +246,3 @@ func Namespace(uri string) Applyer {
h.namespace = uri
})
}

// join is extracted from the stdlib `strings` package
func join(a []string, sep string) string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

@slimsag
Copy link
Member

slimsag commented Oct 14, 2017

Looks great to me. A few inline comments, though. I'll leave the decision of #155 (comment) up to you and we'll go with whatever you decide :)

Could you add a note to https://github.com/gopherjs/vecty/blob/master/doc/CHANGELOG.md ?

This enables component libraries and composition of elements with
classes.

BREAKING: The function `prop.Class(string)` has been removed and
replaced with `vecty.Class(...string)`.  Migrating users must use the
new function and split their classes into separate strings, rather than
a single space-separated string.
@pdf
Copy link
Contributor Author

pdf commented Oct 14, 2017

Added tests that were missing for classes, too.

Copy link
Member

@slimsag slimsag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks @pdf !

@slimsag slimsag merged commit 3afb310 into hexops:master Oct 14, 2017
dmitshur pushed a commit to shurcooL/Go-Package-Store that referenced this pull request Feb 26, 2018
This change updates Go Package Store to use the new Vecty API,
which had breaking changes in hexops/vecty#155 and hexops/vecty#158.

The two main changes include:

-	prop.Class(string) has been replaced with vecty.Class(...string).

-	vecty.Component.Render signature has changed from Render() *vecty.HTML
	to Render() vecty.ComponentOrHTML.

Reference: https://github.com/gopherjs/vecty/blob/19a11ec3acc3ae6c2e095b1ace2b7134c5f28c10/doc/CHANGELOG.md#nov-4-2017-pr-158-major-breaking-change.

Fixes #90.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants