Skip to content
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

Deprecation notice #22

Open
maxpoletaev opened this issue Jan 21, 2017 · 3 comments
Open

Deprecation notice #22

maxpoletaev opened this issue Jan 21, 2017 · 3 comments

Comments

@maxpoletaev
Copy link
Owner

maxpoletaev commented Jan 21, 2017

In jQuery 3.0 was removed the selector property. It was the only way to determine the block if the node has few block-level classes. See example:

<div class="block-a block-b">
  <div class="block-a__elem">
      <div class="block-b__elem"></div>
  </div>
</div>

$('.block-b').elem('elem') should returns .block-b__elem but returns .block-a__elem. The context is unknown, and the block will be determined by the first class on the node.

This change made the plugin fully useless. And now I should mark it as deprecated. Sorry.

Context always creates issues and problems. The best solution to these problems is to rethink and remake the plugin. Some kind of separate abstraction that allows to store the context correctly. Without jQuery.


В jQuery 3.0 было убрано свойство selector. Это был единственный способ понять, какой блок был выбран, если на dom ноде присутствуют несколько классов-блоков. Посмотрите наглядно:

<div class="block-a block-b">
  <div class="block-a__elem">
      <div class="block-b__elem"></div>
  </div>
</div>

$('.block-b').elem('elem') должен вернуть .block-b__elem но вернет .block-a__elem так как контекст теперь неизвестен и блок определится по первому классу на ноде.

Это изменение сделало плагин бесполезным. И я должен отметить его как устаревший и не рекомендуемый к использованию. Извините.

С контекстом всегда было связано несколько багов. И лучшем решением будет все переосмыслить и переделать. Сделать отдельную абстакцию над DOM, которая позволит правильно хранить контекст, без привязки к jQuery.

@EMDM45
Copy link

EMDM45 commented Nov 29, 2021

Существует какое-то альтернативное решение в 2021 году? Не обязательно с привязкой к jQuery.

@maxpoletaev
Copy link
Owner Author

У яндекса вроде еще жива движуха в этом направлении, в частности bem-react

@EMDM45
Copy link

EMDM45 commented Nov 29, 2021

Как я понимаю, движуха была и на момент написания данного плагина для jQ))
Но я имел ввиду не официальное решение. Упрощенное.
Просто для работы с js от BEM (точнее от яндекс) нужно делать какие-то сборки, еще фигову тучу каких-то действий (только что с ними в чате общался). А всё, что мне нужно - просто легко обращаться к блоку и его элементам. Т.е. условно вместо

$('.block').find('.block__element')

Писать

block('block').elem('element')

Конечно можно использовать jQ до 3-й версии, но вдруг что-то еще уже существует :)

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

No branches or pull requests

2 participants