Closed AdamDenoon closed 7 years ago
I've updated the issue to reflect my findings (the undefined issue is based on t
, not cssClasses
)
@AdamDenoon - I need a example to duplicate this. As I said in #4376 -- I ran the NativeScript-Dom inside the demo app (which is in the repo) on both iOS and Android and had no issues using NS 3.x t
is defined properly at that point. So if you can give me a example where this fails I would appreciate it...
@NathanaelA - Here is my app.js at the point I was getting the error:
var application = require("application");
require("nativescript-dom");
require("nativescript-orientation");
var fIcon = require('nativescript-fonticon');
var TNSFontIcon = fIcon.TNSFontIcon;
var fonticon = fIcon.fonticon;
TNSFontIcon.paths = {
'fa': 'font-awesome.css'
};
TNSFontIcon.loadCss();
application.setResources(fonticon);
application.start({ moduleName: "views/login/login" });
I managed to fix it by switching the two plugin requires:
require("nativescript-orientation");
require("nativescript-dom");
So it seems this is an issue with the nativescript-orientation plugin. I'm using nativescript-orientation 1.6.1. After reading the documenation on their repo, it seems they're not compatible with {N} 3.0 yet.
The issue seems to be that nativescript-orientation is calling nativescript-dom in its own orientation.js (line 26), and calling it twice gives the error of this thread.
Since I need a local variable for the orientation in only a single view controller, and since I need nativescript-dom from my app's init, I was able to hack/fix this for myself by commenting out line 26 in orientation.js:
//require('nativescript-dom');
I've opened the issue with nativescript-orientation, and you can follow it here: https://github.com/NathanaelA/nativescript-orientation/issues/19
Affected Platforms
This only seems to be an issue on iOS.
Versions
3.0.3
3.0.1
3.0.1
nativescript-dom: 2.0.0
,tns-core-modules: 3.0.1
Please tell us how to recreate the issue in as much detail as possible.
add
require("nativescript-dom");
to main app.jsIs there code involved? If so, please share the minimal amount of code needed to recreate the problem.
The offending line is 105 in dom.js:
JS ERROR TypeError: undefined is not an object (evaluating 't.cssClasses.forEach')
Adding
console.dir(t)
as Line 104 in dom.js (like this):produces the following output:
CONSOLE LOG file:///app/tns_modules/nativescript-dom/dom.js:104:18: View(undefined)