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

Speedup 3 1 #1438

Merged
merged 355 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
355 commits
Select commit Hold shift + click to select a range
9492b27
Merge remote-tracking branch 'origin/v4' into dsl-speedup
kobezzza Sep 4, 2024
a5d5775
fix: fixed a bug with prop default values
kobezzza Sep 5, 2024
4059f2f
fix: fixed a bug with prop default values
kobezzza Sep 5, 2024
12aec58
Merge remote-tracking branch 'origin/v4' into dsl-speedup
kobezzza Sep 5, 2024
2c3ccdf
fix: fixed an issue with getters and their effect
kobezzza Sep 5, 2024
e77db4d
chore: improved doc
kobezzza Sep 5, 2024
e321f82
chore: updated log
kobezzza Sep 5, 2024
14fcdac
chore: improved doc
kobezzza Sep 5, 2024
2a4c38a
chore: improved doc
kobezzza Sep 5, 2024
d17a546
fix: fixed an issue with @fields
kobezzza Sep 6, 2024
5286a65
chore: use V4_COMPONENT to check whether an object is a component
kobezzza Sep 9, 2024
676ad22
chore: added missing API
kobezzza Sep 9, 2024
751e9fe
chore: removed redundant ts-ignore
kobezzza Sep 9, 2024
6f75125
chore: added doc
kobezzza Sep 9, 2024
a75d2db
chore: componentOriginName -> componentFullName
kobezzza Sep 9, 2024
82376ce
Merge remote-tracking branch 'origin/v4' into dsl-speedup
kobezzza Sep 9, 2024
66058fe
fix: fixed default prop logic
kobezzza Sep 9, 2024
73b5aff
chore: removed redundant logic
kobezzza Sep 9, 2024
b1bcce6
fix: fixed issues with non-objects
kobezzza Sep 10, 2024
4494dca
chore: removed redundant Async contexts
kobezzza Sep 10, 2024
e913e79
fix: fixed an issues with deactivation
kobezzza Sep 10, 2024
d56e992
fix: fixes issues with maps
kobezzza Sep 10, 2024
c0864f4
fix: fixed an issues with Map
kobezzza Sep 12, 2024
21e6c93
fix: props must be initialized after `beforeRuntime`
kobezzza Sep 12, 2024
7eb45d0
fix: fixed errors during synchronization
kobezzza Sep 12, 2024
7526632
Merge remote-tracking branch 'origin/v4' into dsl-speedup
kobezzza Sep 12, 2024
06676f4
chore: fixed eslint
kobezzza Sep 12, 2024
365849f
fix: reverted
kobezzza Sep 12, 2024
26c2bec
fix: reverted
kobezzza Sep 12, 2024
c442539
fix: reverted
kobezzza Sep 13, 2024
ba65d31
feat: added support for property descriptors
kobezzza Sep 13, 2024
873d434
fix: fixes bugs
kobezzza Sep 13, 2024
e65dfac
Merge remote-tracking branch 'origin/v4' into dsl-speedup
kobezzza Sep 13, 2024
29277c4
chore: speedup
kobezzza Sep 13, 2024
cb15e39
fix: fixed isComponent check
kobezzza Sep 13, 2024
d73dfac
refactor: use getters for friendly classes
kobezzza Sep 16, 2024
c106500
Merge branch 'v4' into dsl-speedup
kobezzza Sep 16, 2024
df6111a
refactor: better structure
kobezzza Sep 16, 2024
34f8f39
fix: fixed `once` modifier for hook handlers
kobezzza Sep 16, 2024
453381b
refactor: use Array.toArray
kobezzza Sep 16, 2024
b01a4b2
refactor: test -> shouldInit
kobezzza Sep 16, 2024
afceb80
fix: retrieving information about the observed field should be done i…
kobezzza Sep 17, 2024
dc03f6d
Merge remote-tracking branch 'origin/v4' into dsl-speedup
kobezzza Sep 17, 2024
8bc70ce
fix: don't create abstract smart components
kobezzza Sep 17, 2024
49eed5a
refactor: moved to composition API
kobezzza Sep 20, 2024
e797d77
feat: added a method to determine which specific props have been adde…
kobezzza Sep 24, 2024
90e7b05
chore: added an optimization that prevents watching a prop if it is n…
kobezzza Sep 24, 2024
d6e9a18
chore: stylish fixes
kobezzza Sep 24, 2024
6b08843
Merge branch 'v4' into speedup-2
kobezzza Sep 24, 2024
bcd8206
fix: fixed bugs
kobezzza Sep 24, 2024
5f60ec9
fix: fixed a typo
kobezzza Sep 24, 2024
6854d14
fix: fixed bugs
kobezzza Sep 24, 2024
8f23dd6
fix: fixed `getPassedProps` for functional components
kobezzza Sep 24, 2024
b2c0807
chore: refactoring
kobezzza Sep 24, 2024
eebbf5e
fix: fixed bugs
kobezzza Sep 24, 2024
6be75c6
fix: fixed bugs
kobezzza Sep 24, 2024
a6b6f44
fix: fixed using with a comment' node
kobezzza Sep 24, 2024
e38da6e
fix: fixed beforeCreate/created hooks
kobezzza Sep 24, 2024
9ab389a
fix: fixed bugs
kobezzza Sep 24, 2024
8bf7c33
feat: added support for `renderTracked` & fixed bugs
kobezzza Sep 25, 2024
c71780f
Merge branch 'v4' into dsl-speedup
kobezzza Sep 25, 2024
75f88ee
fix: fixed override
kobezzza Sep 25, 2024
efd3a46
Merge branch 'dsl-speedup' into speedup-2
kobezzza Sep 25, 2024
98be900
chore: optimization
kobezzza Sep 25, 2024
9bb1e2d
refactor: extract to the helper
kobezzza Sep 26, 2024
6772781
chore: fixed eslint
kobezzza Sep 26, 2024
4d0b31f
chore: respect `functional: false` & `functionalWatching: false`
kobezzza Sep 26, 2024
0148ad4
chore: better naming
kobezzza Sep 26, 2024
eedadf2
fix: fixed check
kobezzza Sep 26, 2024
10374ce
chore: optimization
kobezzza Sep 26, 2024
ae3b78f
fix: fixed `modsProp` optimization
kobezzza Sep 26, 2024
135e8f5
chore: stylish fixes
kobezzza Sep 27, 2024
86f3426
chore: refactoring & optimization
kobezzza Sep 27, 2024
a9df80a
chore: removed redundant code
kobezzza Sep 27, 2024
7ad9a73
chore: refactoring
kobezzza Sep 27, 2024
c43cdb7
chore: stylish fixes
kobezzza Sep 27, 2024
f7f2042
chore: removed redundant optimizations
kobezzza Sep 27, 2024
20e5500
chore: stylish fixes
kobezzza Sep 27, 2024
76d47bb
chore: stylish fixes
kobezzza Sep 27, 2024
d41d9b5
chore: stylish fixes
kobezzza Sep 27, 2024
ab3ac2d
chore: fixed eslint
kobezzza Sep 30, 2024
d0cf66d
chore: optimization
kobezzza Sep 30, 2024
ae186f7
chore: optimized accessors initializing
kobezzza Sep 30, 2024
157c40d
chore: refactoring
kobezzza Sep 30, 2024
e95d33c
fix: fixes after refactoring
kobezzza Sep 30, 2024
3d7bad0
chore: optimization
kobezzza Sep 30, 2024
4f5e483
chore: stylish fixes
kobezzza Sep 30, 2024
399bbaa
chore: optimization
kobezzza Sep 30, 2024
07c8381
feat: added the new prop `getPassedHandlers`
kobezzza Oct 1, 2024
ae8aa69
fix: fixed the `emit` optimization
kobezzza Oct 1, 2024
fd62143
chore: optimize event API
kobezzza Oct 2, 2024
aebabb5
chore: optimization
kobezzza Oct 2, 2024
f225aa2
chore: optimization
kobezzza Oct 2, 2024
3ff0c19
chore: optimization
kobezzza Oct 2, 2024
ee92a87
Merge remote-tracking branch 'origin/v4' into speedup-3-1
kobezzza Oct 2, 2024
6d18921
chore: updated tests
kobezzza Oct 2, 2024
b28f6e8
fix: fixes after refactoring
kobezzza Oct 3, 2024
53a9c55
fix: fixes after refactoring
kobezzza Oct 3, 2024
099f6b0
chore: updated tests
kobezzza Oct 3, 2024
7dcfd77
chore: removed only
kobezzza Oct 3, 2024
533f467
chore: updated tests
kobezzza Oct 3, 2024
52e9de6
Merge remote-tracking branch 'origin/v4' into speedup-3-1
kobezzza Oct 3, 2024
78b814c
chore: removed redundant normalization
kobezzza Oct 3, 2024
c8f8c65
chore: optimization
kobezzza Oct 3, 2024
d8660b0
fix: fixes after refactoring
kobezzza Oct 3, 2024
6a8322e
fix: reverted br
kobezzza Oct 3, 2024
7094997
fix: fixes after refactoring
kobezzza Oct 3, 2024
8b04aef
fix: updated tests
kobezzza Oct 3, 2024
fa8e7b2
fix: init dependencies on created
kobezzza Oct 3, 2024
64711bc
Merge remote-tracking branch 'origin/v4' into speedup-3-1
kobezzza Oct 3, 2024
13f1e01
chore: optimization
kobezzza Oct 4, 2024
2b968a6
refactor: extract @watch from factory
kobezzza Oct 8, 2024
540f298
chore: stylish fixes
kobezzza Oct 8, 2024
41b593c
chore: better typings
kobezzza Oct 8, 2024
43ff8c4
refactor: extract @field/@system from factory
kobezzza Oct 8, 2024
4ea39f6
refactor: extract @prop from factory
kobezzza Oct 8, 2024
3cbcd00
chore: stylish fixes
kobezzza Oct 8, 2024
4180a15
refactor: extract @hook from factory
kobezzza Oct 8, 2024
cee9cfd
refactor: extract @computed from factory
kobezzza Oct 8, 2024
6cc363f
fix: fixes after refactoring
kobezzza Oct 9, 2024
378fda6
refactor: optimized meta creation
kobezzza Oct 9, 2024
ee10fba
chore: better naming
kobezzza Oct 9, 2024
7f5bf30
fix: fixes after refactoring & optimization
kobezzza Oct 9, 2024
ae2e788
fix: better use init
kobezzza Oct 9, 2024
ffdf936
chore: optimization
kobezzza Oct 9, 2024
86636ee
chore: optimization
kobezzza Oct 9, 2024
621dba8
chore: optimization
kobezzza Oct 9, 2024
fee0eaf
chore: optimization
kobezzza Oct 9, 2024
57c287f
chore: refactoring & optimization
kobezzza Oct 10, 2024
739f8e8
fix: fixes after refactoring
kobezzza Oct 10, 2024
fccb862
fix: fixes after refactoring
kobezzza Oct 14, 2024
b916fb6
fix: fixes after refactoring
kobezzza Oct 14, 2024
391cf40
fix: fixes propName normalization
kobezzza Oct 15, 2024
b0ca336
fix: fixes after refactoring
kobezzza Oct 15, 2024
4e05cff
fix: fixes prop normalization
kobezzza Oct 15, 2024
b772ee9
fix: fixes after refactoring
kobezzza Oct 15, 2024
5c08c79
fix: fixes after refactoring
kobezzza Oct 15, 2024
a417b31
chore: stylish fixes
kobezzza Oct 15, 2024
ab0dd8f
feat: added the new @defaultValue decorator
kobezzza Oct 16, 2024
d146329
feat: added a transformer for registering default values on component…
kobezzza Oct 16, 2024
19e5de8
docs: added doc
kobezzza Oct 16, 2024
fb0f740
docs: improved doc
kobezzza Oct 16, 2024
854e5a7
chore: fixed a typo
kobezzza Oct 16, 2024
76e45c7
docs: improved doc
kobezzza Oct 16, 2024
8b4c325
refactor: prefer constructor
kobezzza Oct 16, 2024
d34170e
chore: optimized default values
kobezzza Oct 16, 2024
1fe0b82
fix: fixed issues with static properties
kobezzza Oct 16, 2024
be52946
refactor: improved DSL transformer
kobezzza Oct 17, 2024
1274c41
chore: improved doc
kobezzza Oct 17, 2024
1026cbe
chore: optimized dsl decorators
kobezzza Oct 17, 2024
f1176ca
feat: added a new decorator `method`
kobezzza Oct 17, 2024
ec1b559
feat: added a new decorator @derive for components
kobezzza Oct 17, 2024
49072bc
chore: use new @derive
kobezzza Oct 17, 2024
30db8c5
chore: removed `addMethodsToMeta`
kobezzza Oct 17, 2024
571a66e
chore: stylish fixes
kobezzza Oct 17, 2024
b75754e
chore: optimized meta inheritance
kobezzza Oct 17, 2024
1be8853
chore: review
kobezzza Oct 17, 2024
5be5ddd
feat: added support for `this` within default values
kobezzza Oct 17, 2024
9ae28af
chore: optimization
kobezzza Oct 17, 2024
9e5263c
fix: reg methods after properties
kobezzza Oct 17, 2024
bfcb971
fix: fix after refactoring
kobezzza Oct 17, 2024
62d56bf
fix: reverted after:bindConstructor
kobezzza Oct 17, 2024
15d7293
chore: stylish fixes
kobezzza Oct 17, 2024
246d4a8
chore: stylish fixes
kobezzza Oct 20, 2024
d4c009c
chore: stylish fixes
kobezzza Oct 20, 2024
a19c306
fix: fixed overriding
kobezzza Oct 21, 2024
5b93191
chore: optimization
kobezzza Oct 21, 2024
bdd54c1
chore: optimization
kobezzza Oct 21, 2024
05fb9ec
refactor: generate getters/setters using transformers
kobezzza Oct 21, 2024
8e26952
fix: fixed modifier initializing
kobezzza Oct 21, 2024
1236082
fix: fixes after refactoring
kobezzza Oct 22, 2024
827e092
fix: provide parameters to setter
kobezzza Oct 22, 2024
a53ceb4
chore: added FIXME & stylish fixes
kobezzza Oct 22, 2024
c9e41d0
Merge remote-tracking branch 'origin/v4' into speedup-3-1
kobezzza Oct 22, 2024
95ddc36
fix: fixes after refactoring
kobezzza Oct 22, 2024
4d3e763
fix: fixed prop normalization
kobezzza Oct 23, 2024
44d1329
fix: fixes after refactoring
kobezzza Oct 23, 2024
74565de
chore: reverted methods from prototype for functional components
kobezzza Oct 23, 2024
b750eb2
fix: don't provide internal props
kobezzza Oct 23, 2024
9e06bb9
fix: fixes after refactoring
kobezzza Oct 23, 2024
ea8ba1b
fix: fixes after refactoring
kobezzza Oct 24, 2024
3986851
chore: stylish fixes
kobezzza Oct 25, 2024
35ff0df
chore: stylish fixes
kobezzza Oct 25, 2024
8ebbe15
fix: theme initialization
kobezzza Oct 25, 2024
84fc757
fix: merging modifiers
kobezzza Oct 25, 2024
82394d3
fix: avoid Vue warnings
kobezzza Oct 25, 2024
45b6b27
fix: merging state
kobezzza Oct 25, 2024
a7bc3e8
chore: optimization
kobezzza Oct 25, 2024
03a519a
chore: stylish fixes
kobezzza Oct 25, 2024
184e46a
fix: node can be null
kobezzza Oct 25, 2024
c907994
fix: fixed the test
kobezzza Oct 25, 2024
c32cc59
fix: theme initializing
kobezzza Oct 25, 2024
79c66ec
fix: fixed functional default values
kobezzza Oct 25, 2024
59d6edb
fix: fixed functional default values
kobezzza Oct 25, 2024
535d980
fix: fixed initializing of getter dependencies
kobezzza Oct 25, 2024
2d05e67
fix: fixed initializing of getter dependencies
kobezzza Oct 29, 2024
981fcea
fix: initializing order
kobezzza Oct 29, 2024
c5aae9c
chore: stylish fixes
kobezzza Oct 29, 2024
a688818
fix: fixed computed overriding
kobezzza Nov 1, 2024
1677d0e
refactor: optimization from speedup-3-2
kobezzza Nov 6, 2024
b2ac699
chore: fixed test
kobezzza Nov 6, 2024
5cbcc9a
Merge remote-tracking branch 'origin/v4' into speedup-3-1
kobezzza Nov 6, 2024
7231e88
chore: updated example
kobezzza Nov 6, 2024
3fef7cf
refactor: removed `forceDefault` & `defaultProps`; now `getPassedProp…
kobezzza Nov 7, 2024
bfdc475
chore: provide `isPros` for vue sfc
kobezzza Nov 7, 2024
6d9ddf4
refactor: removed idle initializing
kobezzza Nov 7, 2024
245f349
chore: stylish fixes
kobezzza Nov 7, 2024
d7f14aa
refactor: use instance
kobezzza Nov 7, 2024
94d0baa
chore: fixed linters
kobezzza Nov 7, 2024
bae7f06
chore: improved TS type inferring
kobezzza Nov 7, 2024
66221b4
chore: fixed linters
kobezzza Nov 7, 2024
c3e93dd
chore: fixed linters
kobezzza Nov 7, 2024
7a12767
refactor: simplify types
kobezzza Nov 7, 2024
174a1fc
chore: optimization
kobezzza Nov 8, 2024
11cb6b8
chore: added log
kobezzza Nov 8, 2024
1802747
chore: doc fixes
kobezzza Nov 8, 2024
d60ef21
refactor: use only native idle
kobezzza Nov 8, 2024
28ffe28
chore: added memoization
kobezzza Nov 8, 2024
40ecc92
chore: removed idle
kobezzza Nov 8, 2024
1e848cf
feat: added a static property graph for use in synchronous code
kobezzza Nov 8, 2024
f30c0f9
BREAKING_CHANGE: the passing of the component graph to the runtime ha…
kobezzza Nov 8, 2024
6971afb
chore: added support for the hint in dontWaitRemoteProviders
kobezzza Nov 8, 2024
081128a
refactor: don't use config.componentes
kobezzza Nov 8, 2024
ef6b949
chore: removed dead code
kobezzza Nov 8, 2024
ae1af2f
fix: fixed s typo
kobezzza Nov 8, 2024
ad20b16
chore: fixed linters
kobezzza Nov 8, 2024
506b417
chore: updated log
kobezzza Nov 8, 2024
3913e56
chore: better name
kobezzza Nov 8, 2024
9052b6e
chore: don't store initializers
kobezzza Nov 8, 2024
a956271
chore: added ExclamationToken
kobezzza Nov 8, 2024
3c819c0
chore: generate getters/setters dynamically
kobezzza Nov 8, 2024
d35c161
fix: fixes after refactoring
kobezzza Nov 9, 2024
5002600
Update CHANGELOG.md
kobezzza Nov 12, 2024
fabf43b
Speedup 3 1 shared mods (#1486)
kobezzza Nov 13, 2024
2c0edeb
chore: methods for accessors, such as fooGetter/fooSetter, are used o…
kobezzza Nov 13, 2024
59d4e71
refactor: simplify code
kobezzza Nov 13, 2024
5da52b4
chore: improved doc
kobezzza Nov 13, 2024
20c3889
refactor: better structure
kobezzza Nov 13, 2024
a97f04c
fix: fixed a typo
kobezzza Nov 13, 2024
20abffd
Merge remote-tracking branch 'origin/v4' into speedup-3-1
kobezzza Nov 13, 2024
6461471
fix: fixed linters & optimization
kobezzza Nov 13, 2024
1590d2b
fix: mods initialization
kobezzza Nov 13, 2024
8e65033
fix: mods merging
kobezzza Nov 14, 2024
f444dfb
fix: fixed typos
kobezzza Nov 14, 2024
d629459
chore: better doc
kobezzza Nov 14, 2024
caa43a1
chore: better doc
kobezzza Nov 14, 2024
b3c3c9f
chore: removed log
kobezzza Nov 14, 2024
77a572f
Merge remote-tracking branch 'origin/v4' into speedup-3-1
kobezzza Nov 14, 2024
0996620
fix: modifiers merging
kobezzza Nov 15, 2024
37bf050
Merge remote-tracking branch 'origin/v4' into speedup-3-1
kobezzza Nov 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ _Note: Gaps between patch versions are faulty, broken or test releases._
This decorator is automatically added during the build process.
* Optimized creation of metaobjects.

## v4.0.0-beta.152 (2024-11-11)

#### :rocket: New Feature

* Added `trackContentSwipes` - a flag to prevent unexpected closure of a component instance `bBottomSlide`

## v4.0.0-beta.151 (2024-11-06)

#### :bug: Bug Fix
Expand Down
9 changes: 3 additions & 6 deletions build/graph/component-params.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ const
$C = require('collection.js'),
escaper = require('escaper');

const
fs = require('node:fs');
const fs = require('node:fs');

const {
componentRgxp,
Expand Down Expand Up @@ -67,8 +66,7 @@ Object.assign(componentParams, {
* Load component runtime parameters to a map
*/
componentFiles.forEach((el) => {
const
escapedFragments = [];
const escapedFragments = [];

const
file = escaper.replace(fs.readFileSync(el).toString(), escapedFragments),
Expand All @@ -94,8 +92,7 @@ componentFiles.forEach((el) => {
parent
};

const
obj = componentParams[component];
const obj = componentParams[component];

obj.deprecatedProps = p.deprecatedProps ?? {};

Expand Down
4 changes: 2 additions & 2 deletions build/snakeskin/default-filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ function tagFilter({name: tag, attrs = {}}, _, rootTag, forceRenderAsVNode, tplN
attrs[':componentIdProp'] = [`componentId + ${JSON.stringify(id)}`];
}

if (component.inheritMods !== false && !attrs[':mods'] && !attrs[':modsProp']) {
attrs[':mods'] = ['provide.mods()'];
if (component.inheritMods !== false) {
attrs[':inheritMods'] = ['sharedMods != null'];
}

Object.entries(attrs).forEach(([name, val]) => {
Expand Down
3 changes: 1 addition & 2 deletions src/components/base/b-dynamic-page/b-dynamic-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,6 @@ export default class bDynamicPage extends iDynamicPage {
if (passedProps != null) {
const rejectedProps = {
kobezzza marked this conversation as resolved.
Show resolved Hide resolved
is: true,
keepAlive: true,
dispatching: true,
componentIdProp: true,
getRoot: true,
Expand All @@ -334,7 +333,7 @@ export default class bDynamicPage extends iDynamicPage {
};

Object.entries(passedProps).forEach(([propName, prop]) => {
if (rejectedProps.hasOwnProperty(propName)) {
if (rejectedProps.hasOwnProperty(propName) || this.meta.props.hasOwnProperty(propName)) {
return;
}

Expand Down
14 changes: 7 additions & 7 deletions src/components/friends/block/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ To disable modifier inheritance, pass the `inheridMods: false` option when creat
```typescript
import iBlock, { component } from 'components/super/i-block/i-block';

@component({inheritMods: false})
@component()
class bExample extends iBlock {}
```

Expand All @@ -246,7 +246,7 @@ Please note that the key must be in a dash style, i.e., normalized.
```typescript
import iBlock, { component, ModsDecl } from 'components/super/i-block/i-block';

@component({inheritMods: false})
@component()
class bExample extends iBlock {
static mods: ModsDecl = {
theme: [
Expand All @@ -266,7 +266,7 @@ This property can be observed using the watch API.
```typescript
import iBlock, { component, ModsDecl } from 'components/super/i-block/i-block';

@component({inheritMods: false})
@component()
class bExample extends iBlock {
static mods: ModsDecl = {
theme: [
Expand Down Expand Up @@ -310,7 +310,7 @@ To set a new modifier value or remove an old one, you must use the `setMod` and
```typescript
import iBlock, { component, ModsDecl } from 'components/super/i-block/i-block';

@component({inheritMods: false})
@component()
class bExample extends iBlock {
static mods: ModsDecl = {
theme: [
Expand Down Expand Up @@ -343,7 +343,7 @@ inside and outside the component.
```typescript
import iBlock, { component, ModsDecl } from 'components/super/i-block/i-block';

@component({inheritMods: false})
@component()
class bExample extends iBlock {
static mods: ModsDecl = {
theme: [
Expand Down Expand Up @@ -380,7 +380,7 @@ this can be more convenient than handling each event individually.
```typescript
import iBlock, { component, ModsDecl } from 'components/super/i-block/i-block';

@component({inheritMods: false})
@component()
class bExample extends iBlock {
static mods: ModsDecl = {
theme: [
Expand Down Expand Up @@ -427,7 +427,7 @@ __b-example.ts__
```typescript
import iBlock, { component, ModsDecl } from 'components/super/i-block/i-block';

@component({inheritMods: false})
@component()
class bExample extends iBlock {
mounted() {
const
Expand Down
12 changes: 6 additions & 6 deletions src/components/friends/field/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,26 +164,26 @@ export function deleteField(
prop = keyGetter ? <PropertyKey>keyGetter(chunks[0], ref) : chunks[0];

if (chunks.length > 1) {
chunks.some((chunk, i) => {
for (let i = 0; i < chunks.length; i++) {
const chunk = chunks[i];

prop = keyGetter ? <PropertyKey>keyGetter(chunk, ref) : chunk;

if (i + 1 === chunks.length) {
return true;
break;
}

const newRef = Object.isMap(ref) ? ref.get(prop) : ref[prop];

if (newRef == null || typeof newRef !== 'object') {
needDelete = false;
return true;
break;
}

ref = newRef;
return false;
});
}
}

// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (needDelete) {
if (needDeleteToWatch) {
ctx.$delete(ref, prop);
Expand Down
12 changes: 4 additions & 8 deletions src/components/friends/field/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,11 @@ export function getField<T = unknown>(
}

} else {
const hasNoProperty = chunks.some((chunk) => {
for (let i = 0; i < chunks.length; i++) {
const chunk = chunks[i];

if (res == null) {
return true;
return undefined;
}

if (Object.isPromiseLike(res) && !(chunk in res)) {
Expand Down Expand Up @@ -186,12 +188,6 @@ export function getField<T = unknown>(
res = typeof obj !== 'object' || chunk in obj ? obj[chunk] : undefined;
}
}

return false;
});

if (hasNoProperty) {
return undefined;
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/components/friends/field/set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,13 @@ export function setField<T = unknown>(
let prop = keyGetter ? <PropertyKey>keyGetter(chunks[0], ref) : chunks[0];

if (chunks.length > 1) {
chunks.some((chunk, i) => {
for (let i = 0; i < chunks.length; i++) {
const chunk = chunks[i];

prop = keyGetter ? <PropertyKey>keyGetter(chunk, ref) : chunk;

if (i + 1 === chunks.length) {
return true;
break;
}

type AnyMap = Map<any, any>;
Expand Down Expand Up @@ -198,9 +200,7 @@ export function setField<T = unknown>(
} else {
ref = ref[prop];
}

return false;
});
}
}

// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
Expand Down
22 changes: 9 additions & 13 deletions src/components/friends/provide/mods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,20 @@ import type { Mods } from 'components/friends/provide/interface';
* ```
*/
export function mods(this: Friend, mods?: Mods): CanNull<ModsDict> {
const {sharedMods} = this.ctx;

if (sharedMods == null && mods == null) {
if (mods == null) {
return null;
}

const resolvedMods = {...sharedMods};

if (mods != null) {
const modNames = Object.keys(mods);
const
resolvedMods = {},
modNames = Object.keys(mods);

for (let i = 0; i < modNames.length; i++) {
const
modName = modNames[i],
modVal = mods[modName];
for (let i = 0; i < modNames.length; i++) {
const
modName = modNames[i],
modVal = mods[modName];

resolvedMods[modName.dasherize()] = modVal != null ? String(modVal) : undefined;
}
resolvedMods[modName.dasherize()] = modVal != null ? String(modVal) : undefined;
}

return resolvedMods;
Expand Down
9 changes: 2 additions & 7 deletions src/components/friends/provide/test/unit/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,9 @@ test.describe('friends/provide', () => {
});

test.describe('`mods`', () => {
test('should return a dictionary of active modifiers and their values', async () => {
await test.expect(target.evaluate(({provide}) => provide.mods()))
.resolves.toEqual({foo: 'bar'});
});

test('should return a dictionary of active and provided modifiers and their values', async () => {
test('should return a dictionary of provided modifiers and their values', async () => {
await test.expect(target.evaluate(({provide}) => provide.mods({baz: 'bla'})))
.resolves.toEqual({foo: 'bar', baz: 'bla'});
.resolves.toEqual({baz: 'bla'});
});
});

Expand Down
45 changes: 26 additions & 19 deletions src/components/super/i-block/i-block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export default abstract class iBlock extends iBlockProviders {
this.watch('$attrs', {deep: true}, mountAttrs);
}

function mountAttrs(attrs: Dictionary<string>) {
function mountAttrs(attrs: Dictionary<string | Function>) {
const mountedAttrsGroup = {group: 'mountedAttrs'};
$a.terminateWorker(mountedAttrsGroup);

Expand All @@ -137,34 +137,41 @@ export default abstract class iBlock extends iBlockProviders {
}

attrsStore ??= new Set<string>();
const mountedAttrs = attrsStore;

Object.entries(attrs).forEach(([name, attr]) => {
if (attr == null) {
return;
const
mountedAttrs = attrsStore,
attrNames = Object.keys(attrs);

for (let i = 0; i < attrNames.length; i++) {
const
attrName = attrNames[i],
attrVal = attrs[attrName];

if (attrVal == null) {
continue;
}

if (name === 'class') {
attr.split(/\s+/).forEach((val) => {
node.classList.add(val);
mountedAttrs.add(`class.${val}`);
});
if (attrName === 'class') {
for (const className of (<string>attrVal).split(/\s+/)) {
node.classList.add(className);
mountedAttrs.add(`class.${className}`);
}

} else if (originalNode.hasAttribute(name)) {
node.setAttribute(name, attr);
mountedAttrs.add(name);
} else if (originalNode.hasAttribute(attrName)) {
node.setAttribute(attrName, attrVal);
mountedAttrs.add(attrName);
}
});
}

$a.worker(() => {
mountedAttrs.forEach((attr) => {
if (attr.startsWith('class.')) {
node.classList.remove(attr.split('.')[1]);
for (const attrName of mountedAttrs) {
if (attrName.startsWith('class.')) {
node.classList.remove(attrName.split('.')[1]);

} else {
node.removeAttribute(attr);
node.removeAttribute(attrName);
}
});
}

mountedAttrs.clear();
}, mountedAttrsGroup);
Expand Down
Loading