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

errors when running simple-compiled #100

Open
myphysicslab opened this issue May 9, 2017 · 1 comment
Open

errors when running simple-compiled #100

myphysicslab opened this issue May 9, 2017 · 1 comment

Comments

@myphysicslab
Copy link

When Dossier is compiled using compilation_level = "SIMPLE" (instead of ADVANCED) in two places in src/js/BUILD, then this runtime error:

Exception with thrown value: TypeError: Right hand side of instanceof is not an object.

The problem occurs in code generated from this template in dossier.soy

/**
 * Renders a single row in an info table.
 */
{template .infoRow private="true"}
  {@param? title: html}
  {@param cell1: html}
  {@param? cell1Attributes: attributes}
  {@param? cell2: html}
  {@param? cell2Attributes: attributes}
  {@param? id: string}
  {@param? block: bool}

  <tr class="info-row{if $block} block{/if}" {if $id}id="{$id}"{/if}>
    {if $title}<th class="info-head">{$title}</th>{/if}
    <td class="info-cell" {if $cell1Attributes}{$cell1Attributes}{/if}>{$cell1}</td>
    {if $cell2}
      <td class="info-cell" {if $cell2Attributes}{$cell2Attributes}{/if}>{$cell2}</td>
    {/if}
  </tr>
{/template}

when simple-compiled, the above becomes (in part)

soydata.SanitizedHtmlAttribute || a.cell1Attributes instanceof soydata.UnsanitizedText || 
goog.isString(a.cell1Attributes), "cell1Attributes", a.cell1Attributes, "?
soydata.SanitizedHtmlAttribute|string|undefined");

The problem is there is no property soydata.UnsanitizedText. Similarly, there is also no property soydata.SanitizedHtmlAttribute which cause similar problems later on.

Workaround: Perform the following text replacements after compilation in the resulting output file dossier.js

using regular expressions:

find: soydata\.(UnsanitizedText|SanitizedHtmlAttribute)

replace: goog.soy.data.$1

@jleyba
Copy link
Owner

jleyba commented Jun 17, 2017

I cannot reproduce this at head:

$ bazel build //src/js:dossier_simple
INFO: Found 1 target...
Target //src/js:dossier_simple up-to-date:
  bazel-bin/src/js/dossier_simple.js
  bazel-bin/src/js/dossier_simple.js.map
INFO: Elapsed time: 0.158s, Critical Path: 0.00s

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

No branches or pull requests

2 participants