-
Notifications
You must be signed in to change notification settings - Fork 7
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
Uncaught TypeError: Cannot read property 'split' of undefined #5
Comments
The way I resolved this error is by setting a initial view for the global view variable. It looks like DOMContentLoaded is not updating the view variable fast enough which results is isDesktop(), isLandscape() etc... on page load acting on an undefined variable. I have added a function which just returns the logic to get the current size. I made a few more updates i can request a merge if you would like. Here is what I have done: var view = currentView(),
sizes = ['xs', 's', 'm', 'l', 'xl'];
function currentView() {
try {
var currentView = window.getComputedStyle(document.querySelector('body'), ':after').getPropertyValue('content').replace(/["']/g, '');
return currentView;
} catch(exception) {
console.error(exception);
return 'l landscape'; // assume 1024px wide landscape screen if computed style query fails
}
}
/**
* Get the current view and trigger viewchange event if it changed since last query
*
* @return {string} string from body:after CSS content property
*/
function getView() {
var oldView = view;
view = currentView();
if (oldView !== view && window.hasCustomEvents) {
var event = new window.CustomEvent('viewchange', {'detail': {
'originalView': oldView,
'currentView': view
}});
document.dispatchEvent(event);
}
return view;
} |
Hi @imdpk |
Anzeixer 2.0.1 release, merged pull request for issue #5
I am receiving the following error in my console.
1.3.0 was working fine.
Here seems to be a issue:
The text was updated successfully, but these errors were encountered: