question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Optional attribute support

See original GitHub issue

In some library/wrapper code we need possibility to add attribute value conditionally. Something like this will be really helpfully:

  "OptionAttribute" in {
    val width = Var(scala.Option.empty[Int])

    @dom val td = <td width={width.bind}/>
    td.watch()

    assert(td.value.outerHTML == "<td/>")
    width.value = Some(100)
    assert(td.value.outerHTML == "<td width=100/>")
  }

But implementation such feature in Binding.scala can broke current code with custom tags (if somebody uses suggestion from #4 and has property with type like Option[T])

@Atry, do you think such Binding.scala feature will be useful? /cc @ccamel

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
glmarscommented, Nov 26, 2018

Implementation is slightly different from the example in this issue: only Option[String] is supported, you should use option: prefix in an attribute name… please, see test from PR: https://github.com/ThoughtWorksInc/Binding.scala/pull/103/files#diff-1ee69eb8fca397f2ef7f3efd0f631c03

1reaction
glmarscommented, Oct 11, 2018

I think I understand you. I am going to create PR (unfortunately, an option to assign this task to myself is disabled on this issue).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Optional Attribute (Entity-Relationship Diagram)
The ERD entity consists of required and optional attributes. An optional attribute do not need any value assigned.
Read more >
optional - CSS: Cascading Style Sheets - MDN Web Docs
The :optional CSS pseudo-class represents any , , or element that does not have the required attribute set on it.
Read more >
Support for XML attributes - IBM
Optional attributes. Attributes can be optional or required and can be associated with any element in a SOAP message or XML for an...
Read more >
Use Null Checks for Optional Attributes - Oracle Help Center
If an optional attribute is used in the approval rules, it will lead the server to throw a null pointer exception. The application...
Read more >
Manage Custom Attributes (optional) - GoToAssist Remote ...
A standard set of SCIM-based attributes for users – employeeNumber, costCenter, division, and department ... HELP FILE. Manage Custom Attributes (optional).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found