Skip to content

Commit

Permalink
Fixed the issue with for_each not overwriting
Browse files Browse the repository at this point in the history
- 0.17 changed the code that even with READONLY we can't overwrite via register. Changed it to WRITABLE so we can overwrite the for_each
  • Loading branch information
tkmcmaster committed Jul 16, 2024
1 parent 1f746e7 commit 7fc5d8c
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions lib/config/src/configv2/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl PropagateVars for Query<False> {
// overwrites it. On repeat calls, log the error and continue
.register_global_property(js_string!("_v"), js, Attribute::READONLY)
.map_err(|err| {
log::debug!("register_global_property _v error {}", err);
log::warn!("register_global_property _v error {}", err);
err
})
.unwrap_or_default();
Expand Down Expand Up @@ -185,7 +185,7 @@ impl Clone for QueryInner {
// overwrites it. On repeat calls, log the error and continue
.register_global_property(js_string!("_v"), js, Attribute::READONLY)
.map_err(|err| {
log::debug!("register_global_property _v error {}", err);
log::warn!("register_global_property _v error {}", err);
err
})
.unwrap_or_default();
Expand Down Expand Up @@ -276,12 +276,9 @@ impl QueryInner {
// put the provider values into the context for the query expressions to read
// unlike template expressions, queries access providers directly
.for_each(|(n, o)| {
// NOTE: this function got changed in boa 0.17, where it returns an error if the
// same property is "registered" twice, as opposed to the current behavior which
// overwrites it. On repeat calls, log the error and continue
ctx.register_global_property(js_string!(n.as_str()), o, Attribute::READONLY)
ctx.register_global_property(js_string!(n.as_str()), o, Attribute::WRITABLE)
.map_err(|err| {
log::debug!("register_global_property {} error {}", n, err);
log::warn!("register_global_property {n} error {err}");
err
})
.unwrap_or_default();
Expand Down Expand Up @@ -333,14 +330,9 @@ impl QueryInner {
Ok(for_each
.into_iter()
.map(|x| {
// NOTE: this function got changed in boa 0.17, where it returns an error if the
// same property is "registered" twice, as opposed to the current behavior which
// overwrites it. If it is desired to update the boa engine to a newer version in
// the future, an alternative to this will be needed.
// On repeat calls, log the error and continue
ctx.register_global_property(js_string!("for_each"), x, Attribute::READONLY)
ctx.register_global_property(js_string!("for_each"), x, Attribute::WRITABLE)
.map_err(|err| {
log::debug!("register_global_property for_each error {}", err);
log::warn!("register_global_property for_each error {err}");
err
})
.unwrap_or_default();
Expand Down

0 comments on commit 7fc5d8c

Please sign in to comment.