Skip to content

first/last/nth-child patch for after/before emulation#2

Open
smelukov wants to merge 3 commits into
basisjs:masterfrom
smelukov:nthChild
Open

first/last/nth-child patch for after/before emulation#2
smelukov wants to merge 3 commits into
basisjs:masterfrom
smelukov:nthChild

Conversation

@smelukov

Copy link
Copy Markdown
Member

No description provided.

Sergey Melyukov added 3 commits September 7, 2016 17:54
Comment thread src/utils/style.js
// todo возможно есть более простой способ сфлэтить все селекторы из ast
walk(sourceAst, {
SimpleSelector: function(token) {
token.sequence.each(function(part) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

token.sequence.toArray()

@lahmatiy lahmatiy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

пробежался по диагонали

Comment thread src/module/stage/index.js

// копируем объект и сортируем его свойства
this.condition = sortObject(basis.object.merge(this.condition));
this.states = sortObject(basis.object.merge(this.states));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Зачем merge для одного объекта? лучше slice если нужна копия

Comment thread src/app/lib/variant.js
var firstToken = token.sequence.head;

if (firstToken.data.type == 'Class' && firstToken.data.name == this.wrapperClass) {
token.sequence.remove(token.sequence.first());

@lahmatiy lahmatiy Sep 14, 2016

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

если sequence это инстанс List, то тут не будет удаления (вернее будет что-то странное) и нужно .first() -> .head

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unwrap не проверял
надо глянуть )

Comment thread src/app/lib/variant.js
walk(resource.AST, {
SimpleSelector: function(token, parent) {
token.sequence.each(function(part) {
var emulators = getAllEmulators(this.emulators);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а точно нужно вычислять для каждого новый emulators?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

нет )

Comment thread src/app/lib/variant.js
this.template = this.generator.generate(this.states);
this.wrapperClass = 'dp-variant-wrapper-' + this.basisObjectId;
this.resources = this.resources.map(function(resource) {
return new ProcessableStyleResource({source: resource, useImmediate: true});

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

пробельчики бы для литеральных объектов { source: .., useImmediate: true }

mapper.removeSelector(token);
allowToEmulate.forEach(function(element) {
var existingEmulator = element.querySelector(TYPE_NAME);
var existingEmulator = basis.array.from(element.children).filter(function(child) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

basis.array.find(..., function(child) {
  return child.tagName.toLowerCase() == TYPE_NAME.toLowerCase();
})

var states = [];
var state = {};

state[type] = false;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

module.exports = function pseudoClassFactory(type) {
  var TYPE_NAME = 'pseudo-class-' + type + '__' + basis.genUID();
  var typeState = basis.fn.wrapper(type);
...
  var states = [typeState(false), typeState(true)];


// пропускаем псевдо классы/элементы, иначе querySelectorAll не найдет узлы
if (sourcePart.type != 'PseudoClass' && sourcePart.type != 'PseudoElement') {
if ((sourcePart.type != 'PseudoClass' || sourcePart.type == 'PseudoClass' && sourcePart.name == 'first-element') && sourcePart.type != 'PseudoElement') {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

очень странное место )
переделаю

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants