Titanium JIRA Archive
Appcelerator Community (AC)

[AC-3321] Alloy with HTML Parser not working certain use case - "'undefined' is not a constructor

GitHub Issuen/a
TypeStory
Priorityn/a
StatusClosed
ResolutionInvalid
Resolution Date2014-07-29T07:00:35.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsAlloy
Labelsdefect
ReporterAxil Rolce
AssigneeMauro Parra-Miranda
Created2014-03-26T03:23:02.000+0000
Updated2016-03-08T07:57:45.000+0000

Description

I tried Alloy with HTML parser based on http://developer.appcelerator.com/question/60731/what-is-the-best-way-to-parse-html It works at the beginning and then after going to background and foreground it doesnt work. And causes this error "'undefined' is not a constructor (evaluating 'new htmlparser.DefaultHandler')"; You can download this sample app I made: https://github.com/axilaris/testnavhtmlparser this is the parsing code: https://github.com/axilaris/testnavhtmlparser/blob/master/app/controllers/nextwin.js this is how I call push the window https://github.com/axilaris/testnavhtmlparser/blob/master/app/controllers/index.js here are the parsing code: https://github.com/axilaris/testnavhtmlparser/tree/master/app/assets/lib Steps to reproduce: 1. click nextWindow 2. click getPageandParse - no problem parsing 3. click back - i even tried explicitly closing the window with .close(), didnt work 4. click getPageandParse - the error below pops up Error output: "'undefined' is not a constructor (evaluating 'new htmlparser.DefaultHandler')"; error dump [ERROR] : Script Error { [ERROR] : backtrace = "#0 () at :0"; [ERROR] : line = 17; [ERROR] : message = "'undefined' is not a constructor (evaluating 'new htmlparser.DefaultHandler')"; [ERROR] : name = TypeError; [ERROR] : sourceId = 276543488; [ERROR] : sourceURL = "file:///Users/test/Library/Application%20Support/iPhone%20Simulator/7.0.3-64/Applications/9D672583-9B94-45E8-A75F-9EE090202C13/testnavhtmlparser.app/alloy/controllers/nextwin.js"; I tried backslash on Ti.include, I tried to that particular window. This always happen when the window goes to background and foreground again. Very strange. Titanium SDK 3.2.2 GA Titanium Studio, build: 3.2.1.201402041146 OSX 10.9.2 IOS 7 XCode 5.0.2

Comments

  1. Mostafizur Rahman 2014-07-08

    Hello, We have tested this sample code. This is not titanium bug. Its report coding issue. As per our docs, include mechanism is not supported with Alloy projects. We recommended instead of include method please create a CommonJS module and use the require () method to include external JavaScript code. For more information please visit following link: http://docs.appcelerator.com/platform/latest/#!/api/Titanium-method-include Thanks
  2. Mauro Parra-Miranda 2014-07-29

    Please don't use include in Alloy.

JSON Source