-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
first/last/nth-child patch for after/before emulation #2
base: master
Are you sure you want to change the base?
Conversation
initial nth handler
refactoring
// todo возможно есть более простой способ сфлэтить все селекторы из ast | ||
walk(sourceAst, { | ||
SimpleSelector: function(token) { | ||
token.sequence.each(function(part) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
token.sequence.toArray()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
пробежался по диагонали
}, | ||
childClass: { | ||
template: resource('./template/variant.tmpl'), | ||
init: function() { | ||
Node.prototype.init.call(this); | ||
|
||
// копируем объект и сортируем его свойства | ||
this.condition = sortObject(basis.object.merge(this.condition)); | ||
this.states = sortObject(basis.object.merge(this.states)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Зачем merge для одного объекта? лучше slice если нужна копия
var firstToken = token.sequence.head; | ||
|
||
if (firstToken.data.type == 'Class' && firstToken.data.name == this.wrapperClass) { | ||
token.sequence.remove(token.sequence.first()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
если sequence это инстанс List, то тут не будет удаления (вернее будет что-то странное) и нужно .first()
-> .head
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unwrap не проверял
надо глянуть )
walk(resource.AST, { | ||
SimpleSelector: function(token, parent) { | ||
token.sequence.each(function(part) { | ||
var emulators = getAllEmulators(this.emulators); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
а точно нужно вычислять для каждого новый emulators?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
нет )
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}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
пробельчики бы для литеральных объектов { source: .., useImmediate: true }
@@ -59,7 +72,9 @@ module.exports = function pseudoElementFactory(type, before) { | |||
|
|||
mapper.removeSelector(token); | |||
allowToEmulate.forEach(function(element) { | |||
var existingEmulator = element.querySelector(TYPE_NAME); | |||
var existingEmulator = basis.array.from(element.children).filter(function(child) { |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
очень странное место )
переделаю
No description provided.