Giter Club home page Giter Club logo

rework-namespace-css's People

Contributors

donaldpipowitch avatar geordiemhall avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

rework-namespace-css's Issues

Example doesn't work

Code used:

var gulp = require("gulp");
var rework = require('rework')
rework.namespace = require('rework-namespace-css')

return gulp.src('./style.css')
    .pipe(rework(rework.namespace({ selector: '.gmh', class: 'gmh-' })))
    .pipe(gulp.dest('dist/styles'))

Response from console:

C:\Users\myUser\Desktop\myFolder>node test.js

C:\Users\myUser\Desktop\myFolder\node_modules\css\lib\parse\index.js:130
    css = css.slice(str.length);
              ^
TypeError: Object function prefix(style) {

                function prefixSelector(selector){

                        var sel = selector

                        if (opts.namespaceBody !== false){

                                // Replace body with .body
                                sel = sel.replace(regBody, function(s){
                                        return s.replace('body', '.body')
                                })

                        }

                        if (opts.namespaceHtml !== false){

                                // Replace html with .html
                                sel = sel.replace(regHtml, function(s){
                                        return s.replace('html', '.html')
                                })

                        }

                        if (opts.selector){

                                var root = opts.root || 'html'

                                // TODO: This method would only replace the firs
t instance of root,
                                // so there is a rare bug when there are two cla
sses that both contain root.
                                // eg. if root is 'html' and an element has the
class .html5.html

                                // Add prefix to selector, adding it to the .htm
l part instead of prepending if needed
                                if (sel.indexOf(root) >= 0){
                                        sel = sel.replace(root, root + opts.sele
ctor)
                                } else {
                                        sel = opts.selector + ' ' + sel
                                }

                        }

                        return sel

                }

                function prefixClasses(selector){

                        return selector.split('.').join('.'+(opts.class || ''))

                }

                // Walk all styles
                walk(style, function(rule, node) {

                        // Don't touch keyframes or font-face
                        if (!rule.selectors || rule.selectors.toString().indexOf
('@') >= 0)
                                return rule;

                        rule.selectors = rule.selectors.map(function(selector) {

                                return prefixSelector(prefixClasses(selector))
                        });

                });

        } has no method 'slice'
    at match (C:\Users\myUser\Desktop\myFolder\node_modules\css\lib\parse\index.js:1
30:15)
    at whitespace (C:\Users\myUser\Desktop\myFolder\node_modules\css\lib\parse\index
.js:139:5)
    at rules (C:\Users\myUser\Desktop\myFolder\node_modules\css\lib\parse\index.js:1
09:5)
    at stylesheet (C:\Users\myUser\Desktop\myFolder\node_modules\css\lib\parse\index
.js:81:16)
    at module.exports (C:\Users\myUser\Desktop\myFolder\node_modules\css\lib\parse\i
ndex.js:559:20)
    at rework (C:\Users\myUser\Desktop\myFolder\node_modules\rework\index.js:27:21)
    at Object.<anonymous> (C:\Users\myUser\Desktop\myFolder\test.js:19:11)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)

C:\Users\myUser\Desktop\myFolder>

has no method 'slice'

Hi - I've been playing with this all afternoon and can't get it to work.

Repeatedly getting the following 🐛 error, any help appreciated:

[17:39:27] 'styles' errored after 961 μs Object function prefix(style) {

        function prefixSelector(selector){

            var sel = selector
            console.log('node')

            if (opts.namespaceBody !== false){

                // Replace body with .body
                sel = sel.replace(regBody, function(s){ 
                    return s.replace('body', '.body')
                })

            }

            if (opts.namespaceHtml !== false){

                // Replace html with .html
                sel = sel.replace(regHtml, function(s){ 
                    return s.replace('html', '.html')
                })

            }

            if (opts.selector){

                var root = opts.root || 'html'

                // TODO: This method would only replace the first instance of root,
                // so there is a rare bug when there are two classes that both contain root.
                // eg. if root is 'html' and an element has the class .html5.html

                // Add prefix to selector, adding it to the .html part instead of prepending if needed
                if (sel.indexOf(root) >= 0){
                    sel = sel.replace(root, root + opts.selector)
                } else {
                    sel = opts.selector + ' ' + sel
                }

            }

            return sel

        }

        function prefixClasses(selector){

            return selector.split('.').join('.'+(opts.class || ''))

        }

        // Walk all styles
        walk(style, function(rule, node) {
            // Don't touch keyframes or font-face
            if (!rule.selectors || rule.selectors.toString().indexOf('@') >= 0) 
                return rule;

            rule.selectors = rule.selectors.map(function(selector) {
                return prefixSelector(prefixClasses(selector))
            });

        });

    } has no method 'slice'

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.