React.js blogpost
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- dieIf(!result.isArray, "Not an array") | |
- dieIf(!result.hasSlot(0), "No slot 0") | |
- dieIf(!result.hasSlot(1), "No slot 1") | |
- dieIf(result.hasSlot(2), "Has slot 2") | |
+ dieIf(!result.hasArrayElements, "Not an array") | |
+ dieIf(result.getArraySize != 2, "Array of size != 2") | |
- val elem0 = result.getSlot(0) | |
- dieIf(!elem0.isInstanceOf[String], ...) | |
- val safeHtml = elem0.asInstanceOf[String] | |
+ val elem0 = result.getArrayElement(0) | |
+ dieIf(!elem0.isString, ...) | |
+ val safeHtml = elem0.asString | |
- val elem1 = result.getSlot(1) | |
- dieIf(!elem1.isInstanceOf[ScriptObjectMirror], ...) | |
- val mentionsArrayMirror = elem1.asInstanceOf[ScriptObjectMirror] | |
+ val elem1 = result.getArrayElement(1) | |
+ dieIf(!elem1.hasArrayElements, ...) | |
+ val mentionsArrayMirror = elem1 | |
val mentions = ArrayBuffer[String]() | |
var nextSlotIx = 0 | |
- while (mentionsArrayMirror.hasSlot(nextSlotIx)) { | |
- val elem = mentionsArrayMirror.getSlot(nextSlotIx) | |
- dieIf(!elem.isInstanceOf[String], ...) | |
- mentions.append(elem.asInstanceOf[String]) | |
- nextSlotIx += 1 | |
- } | |
+ while (nextSlotIx < mentionsArrayMirror.getArraySize) { | |
+ val elem = mentionsArrayMirror.getArrayElement(nextSlotIx) | |
+ dieIf(!elem.isString, ...) | |
+ mentions.append(elem.asString) | |
+ nextSlotIx += 1 | |
+ } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment