Giter Club home page Giter Club logo

Comments (5)

fgiannar avatar fgiannar commented on May 20, 2024 1

Just an update, in case anyone else faces the same issue:
The mistake was passing the selectors collection instead of array of models, so replacing:
cssComposer.add(target.get('selectors'), '', '480px');
with
cssComposer.add(target.get('selectors').models, '', '480px');
fixed the issue.

Again thanks for your time.

from grapesjs.

artf avatar artf commented on May 20, 2024

Hi @fgiannar
sorry but I can't reproduce the bug
Anyway, the return of rule.get('selectors').add(selectors) should be the "same" selectors array

var sm = editor.SelectorManager;
var sel1 = sm.add('myClass1');
var sel2 = sm.add('myClass2');
var selectors = [sel1, sel2]; 

var cssComposer = editor.CssComposer;
var rule = cssComposer.add(selectors, 'hover');
//...
// And inside the add()... when you are at 173 line:
var addedSelectors = rule.get('selectors').add(selectors); 
/*
'addedSelectors' and 'selectors' are 2 different arrays but contain
the same instances of sel1 and sel2
*/

Do you have some use case inside the editor where I can catch some strange behaviour?

from grapesjs.

fgiannar avatar fgiannar commented on May 20, 2024

No I'm afraid not. This occurred from a custom script of mine, where I had:
cssComposer.add(target.get('selectors'), '', '480px'); where target is an instance of a CssRule with maxWidth not set.

If I replaced the line 173, as explained in my first comment above, the selector models had ids else they had the name attribute set but empty id which lead me to think it's a general bug.

Probably my bad, I am closing it since it's not reproducible on your end.
Thanks a lot for your prompt response.

from grapesjs.

artf avatar artf commented on May 20, 2024

Hi @fgiannar I think I get it, target.get('selectors') returns a Backbone Collection but cssComposer.add accepts Array as the first argument, so you should fix with this:
cssComposer.add(target.get('selectors').models, '', '480px');

from grapesjs.

lock avatar lock commented on May 20, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

from grapesjs.

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.