emadalam / atvjs

Blazing fast Apple TV application development using pure JavaScript
https://emadalam.github.io/atvjs
MIT License
311 stars 49 forks source link

DOMParser is not defined #7

Closed teawithfruit closed 8 years ago

teawithfruit commented 8 years ago

Hey. First, thanks for your work. I think, that this project can be very useful, but I got the following problem.

I've created an index.js file with the following content, based on your example code.

var ATV = require('atvjs');

ATV.Page.create({
    name: 'home',
    // use a template function from your favourite templating engine
    // or pass a raw template function
    template(data) {
        return `<document>
                    <alertTemplate>
                        <title>${data.title}</title>
                        <description>${data.description}</description>
                    </alertTemplate>
                </document>`;
    },
    // pass some raw data to be applied
    // or a data function that returns the data
    data: {
        title: 'Homepage',
        description: 'This is my super awesome homepage created using atvjs.'
    }
});

// later in your application you can do something like below to navigate to the page
ATV.Navigation.navigate('home');

I'm using Node.js 4.4.0. And the following error ist the result of that.

/srv/www/SUB.DOMAIN.TLD/www/node_modules/atvjs/dist/atv.js:18710
    var parser = new DOMParser(); // native DOM parser
                     ^

ReferenceError: DOMParser is not defined
    at Object._typeof (/srv/www/SUB.DOMAIN.TLD/www/node_modules/atvjs/dist/atv.js:18710:19)
    at __webpack_require__ (/srv/www/SUB.DOMAIN.TLD/www/node_modules/atvjs/dist/atv.js:34:30)
    at Object.<anonymous> (/srv/www/SUB.DOMAIN.TLD/www/node_modules/atvjs/dist/atv.js:77:16)
    at __webpack_require__ (/srv/www/SUB.DOMAIN.TLD/www/node_modules/atvjs/dist/atv.js:34:30)
    at /srv/www/SUB.DOMAIN.TLD/www/node_modules/atvjs/dist/atv.js:54:18
    at /srv/www/SUB.DOMAIN.TLD/www/node_modules/atvjs/dist/atv.js:57:10
    at webpackUniversalModuleDefinition (/srv/www/SUB.DOMAIN.TLD/www/node_modules/atvjs/dist/atv.js:7:20)
    at Object.<anonymous> (/srv/www/SUB.DOMAIN.TLD/www/node_modules/atvjs/dist/atv.js:14:3)
    at Module._compile (module.js:435:26)
    at Object.Module._extensions..js (module.js:442:10)

Do you have any idea how this can be fixed?

Thanks.

emadalam commented 8 years ago

@teawithfruit Can you give more context of where and how are you trying to run your project. You can upload your project to github and give the link here. Seems like the file that you created is not run in the TVJS context, please give further details for me to debug your specific issue.

On a sidenote you can refer to https://github.com/emadalam/tvml-catalog-using-atvjs to see the sample usage.

teawithfruit commented 8 years ago

You are right. I misunderstood the project structure. My fault was, that I used to run the code with Node.js itself. Now after testing your tvml catalog I know, that I only have to serve the files with a webserver. Thank you for your support.