File tree Expand file tree Collapse file tree 4 files changed +17
-1
lines changed
core/src/main/scala/japgolly/scalajs/react/vdom
test/src/test/scala/japgolly/scalajs/react Expand file tree Collapse file tree 4 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ case $# in
88 COMP_NAMES_ARE_ELIDABLE
99 DEVONLY
1010 ELIDABLE_AUTO_COMPONENT_NAME
11+ ELIDABLE_VDOM_ATTR
1112 REUSABILITY_OVERRIDE_TEST
1213 )
1314 for t in " ${terms[@]} " ; do
Original file line number Diff line number Diff line change 11package japgolly .scalajs .react .vdom
22
33import org .scalajs .dom
4- import scala .annotation .{implicitNotFound , nowarn }
4+ import scala .annotation .{elidable , implicitNotFound , nowarn }
55import scala .scalajs .LinkingInfo .developmentMode
66import scala .scalajs .js
77import japgolly .scalajs .react .internal .OptionLike
@@ -52,6 +52,16 @@ object Attr {
5252 else
5353 Dud
5454
55+ def elidable [A ](name : => String ): Attr [A ] = {
56+ @ elidable(scala.annotation.elidable.FINEST )
57+ def attempt : Attr [A ] = new Generic (name)
58+ val x = attempt
59+ if (x eq null )
60+ Dud
61+ else
62+ x
63+ }
64+
5565 class Generic [- U ](attrName : String ) extends Attr [U ](attrName) {
5666 override def := [A ](a : A )(implicit t : ValueType [A , U ]): TagMod =
5767 t(attrName, a)
Original file line number Diff line number Diff line change 11# 1.7.2
22
33* Fix: no longer generate warnings when ` -Wunused:nowarn ` is enabled
4+ * Add ` VdomAttr.elidable ` which allows you to elide VDOM attributes with ` scalacOptions `
Original file line number Diff line number Diff line change @@ -29,9 +29,13 @@ object ElisionTest extends TestSuite {
2929 .build
3030 }
3131
32+ private val attr =
33+ VdomAttr .elidable(" data-ELIDABLE_VDOM_ATTR" )
34+
3235 override def tests = Tests {
3336 " normal" - s " [ ${Normal .raw.displayName}] "
3437 " static" - s " [ ${Static .raw.displayName}] "
38+ " attr" - ReactDOMServer .renderToStaticMarkup(< .div(attr := 1 ))
3539
3640 " reusabilityOverride" - {
3741 ScalaJsReactConfig .DevOnly .overrideReusability(reusabilityOverride)
You can’t perform that action at this time.
0 commit comments