GithubHelp home page GithubHelp logo

Replace jsdom with cheerio about jqueryui.com HOT 9 CLOSED

jquery avatar jquery commented on June 2, 2024
Replace jsdom with cheerio

from jqueryui.com.

Comments (9)

scottgonzalez avatar scottgonzalez commented on June 2, 2024

I attempted this, but cheerio is acting strange. I need to call $.root() to make it work and the syntax highlighted demos ended up busted.

https://github.com/jquery/jqueryui.com/compare/cheerio

from jqueryui.com.

jzaefferer avatar jzaefferer commented on June 2, 2024

No clue what's going on. Not helping that docs for node-htmlparser options are supposed to be here, but there is no page there: https://github.com/FB55/node-htmlparser/wiki/DOMHandler

from jqueryui.com.

jzaefferer avatar jzaefferer commented on June 2, 2024

I spend some time with this. I still don't know what cheerio is doing, but I was unable to reproduce the problem in a standalone script, that was doing pretty much the same thing.

One thing I found is this: When doing cheerio.load with just the syntaxhighlight wrapper pre and code, console.logging should look like this:

{ '0': 
   { type: 'tag',
     name: 'code',
     attribs: { 'data-linenum': 'true' },
     parent: 
      { type: 'tag',
        name: 'pre',
        children: [Object],
        attribs: {},
        parent: [Object],
        prev: null,
        next: null },
     prev: null,
     next: null,
     children: [] },
  length: 1 }

Inside build-demos, I get this instead:

{ '0': 'code', length: 1, _root: [Circular] }

The code to create the elements for that output are pretty much the same, the result is very different. In the second case, manipulation methods fail with weird exceptions.

from jqueryui.com.

jzaefferer avatar jzaefferer commented on June 2, 2024

Grunt is to blame, it works fine outside grunt. Likely culprit: colors module, as that modifies String.prototype. Hard to verify, as a ton of modules depend on grunt, loading colors everywhere...

from jqueryui.com.

jzaefferer avatar jzaefferer commented on June 2, 2024

Tried running a local grunt without loading any plugins, kicking out the require('colors'), doesn't help. Can't tell what exactly screws up cheerio.

from jqueryui.com.

scottgonzalez avatar scottgonzalez commented on June 2, 2024

Well, at least this gives us something to run with. I'm sure we can track it down from here.

from jqueryui.com.

cowboy avatar cowboy commented on June 2, 2024

Let me know what you figure out.

from jqueryui.com.

theSmaw avatar theSmaw commented on June 2, 2024

I had the same problem, and have tracked it down to

grunt/node_modules/jshint/packages/jshint/jshint.js - line 842

Removing the block below gets Cheerio working properly for me in Grunt again.

I"ll investigate a longer-term solution.

if (typeof String.prototype.name !== 'function') {
        String.prototype.name = function () {

// If the string looks like an identifier, then we can return it as is.
// If the string contains no control characters, no quote characters, and no
// backslash characters, then we can simply slap some quotes around it.
// Otherwise we must also replace the offending characters with safe
// sequences.

            if (ix.test(this)) {
                return this;
            }
            if (nx.test(this)) {
                return '"' + this.replace(nxg, function (a) {
                    var c = escapes[a];
                    if (c) {
                        return c;
                    }
                    return '\\u' + ('0000' + a.charCodeAt().toString(16)).slice(-4);
                }) + '"';
            }
            return '"' + this + '"';
        };
    }

from jqueryui.com.

theSmaw avatar theSmaw commented on June 2, 2024

Ahh super, upgraded to grunt 3.1.17 which uses a version of JSHint that doesn't tamper with native objects.

from jqueryui.com.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.