Skip to content
This repository has been archived by the owner on Feb 22, 2018. It is now read-only.

double quotes just outside a mustache confuses the angular parser #937

Closed
trinarytree opened this issue Apr 22, 2014 · 4 comments
Closed

Comments

@trinarytree
Copy link

to reproduce:
git clone https://github.com/angular/angular.dart.tutorial
cd angular.dart.tutorial/Chapter_03
pub install
python -m SimpleHTTPServer
replace web/index.html with this

<!DOCTYPE html>
<html ng-app>
  <body>
    "{{true}}"
    <script src="packages/shadow_dom/shadow_dom.min.js"></script>
    <script type="application/dart" src="main.dart"></script>
    <script type="text/javascript" src="packages/browser/dart.js"></script>
  </body>
</html>

navigate to localhost:8000/web/index.html with chromium

you will see a stack trace coming from angular:
Bad state: Can not watch expression containing ';'.

STACKTRACE:

#0      ExpressionVisitor._notSupported (package:angular/core/scope.dart:1094:5)
#1      ExpressionVisitor.visitChain (package:angular/core/scope.dart:1090:18)
#2      Chain.accept (package:angular/core/parser/syntax.dart:73:48)
#3      DynamicExpression.accept (package:angular/core/parser/dynamic_parser.dart:46:48)
#4      ExpressionVisitor.visit (package:angular/core/scope.dart:984:15)
#5      _AstParser.call (package:angular/core/scope.dart:968:73)
...

set a breakpoint in scope.dart:1094, then ascend the call stack
to see what's happening at Scope.watch inside scope.dart:228.
inspect the 'expression' variable and you will see

"
  ""+(true|stringify)+""
  "

yes, the double quotes here are literal. so i'm saying that
expression[0] == '"' and
expression[1] == '\n', etc.
the page will also display "{{true}}", which is wrong.
you shouldn't see the {{}}.

now change index.html: replace "{{true}}" by a{{true}}b.
so all i've done here is replace the double quotes with the "simpler" delimiters a and b.
reload the page and you will see no error and it will correctly display atrueb.

@vicb
Copy link
Contributor

vicb commented Apr 22, 2014

@vsavkin could you check this one ? (Bad state: Can not watch expression containing ';'.)

@vsavkin
Copy link
Contributor

vsavkin commented Apr 22, 2014

@vicb

It seems like the issue was introduced between 0.9.10 and 0.9.11.

Angular 0.9.10:
It works fine.

Angular 0.9.11:
It throws "Bad state: Can not watch expression containing ';'.".

Angular 0.10.0:
It throws "Parser Error: '+(true|stringify)+' is an unexpected token". The change of the error message is the result of merging #905.

I'll look into it more this evening and try to fix it.

@vicb
Copy link
Contributor

vicb commented Apr 22, 2014

Thanks!

vsavkin added a commit to vsavkin/angular.dart that referenced this issue Apr 23, 2014
…uotes

Fix a bug in the interpolate function causing it not to handle expressions containing double quotes properly.

Closes dart-archive#937
@vsavkin
Copy link
Contributor

vsavkin commented Apr 23, 2014

@vicb PR #944

vsavkin added a commit to vsavkin/angular.dart that referenced this issue Apr 23, 2014
…uotes

Fix a bug in the interpolate function causing it not to handle expressions containing double quotes properly.

Closes dart-archive#937
vsavkin added a commit to vsavkin/angular.dart that referenced this issue Apr 23, 2014
…uotes

Fix a bug in the interpolate function causing it not to handle expressions containing double quotes properly.

Closes dart-archive#937
jbdeboer pushed a commit that referenced this issue Apr 30, 2014
…uotes

Fix a bug in the interpolate function causing it not to handle expressions containing double quotes properly.

Closes #937
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging a pull request may close this issue.

3 participants