Skip to content

Commit 43dc2c6

Browse files
committed
Remove allow_unsafe_jscode
1 parent 36eaf17 commit 43dc2c6

File tree

7 files changed

+856
-160
lines changed

7 files changed

+856
-160
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
setuptools.setup(
99
name="streamlit-condition-tree",
10-
version="0.1.3",
10+
version="0.2.0",
1111
author="Cédric Villette",
1212
author_email="[email protected]",
1313
description="Condition Tree Builder for Streamlit",

streamlit_condition_tree/__init__.py

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import streamlit as st
44
import streamlit.components.v1 as components
5-
from streamlit.components.v1.custom_component import MarshallComponentException
65

76
_RELEASE = False
87

@@ -35,9 +34,8 @@
3534
# Thanks andfanilo
3635
class JsCode:
3736
def __init__(self, js_code: str):
38-
"""Wrapper around a js function to be injected on gridOptions.
39-
code is not checked at all.
40-
set allow_unsafe_jscode=True on AgGrid call to use it.
37+
"""Wrapper around a js function to be injected on config.
38+
Code is not checked at all.
4139
Code is rebuilt on client using new Function Syntax (https://javascript.info/new-function)
4240
4341
Args:
@@ -108,7 +106,7 @@ def condition_tree(config: dict,
108106
placeholder: str = '',
109107
always_show_buttons: bool = False,
110108
key: str = None,
111-
allow_unsafe_jscode: bool = False, ):
109+
):
112110
"""Create a new instance of condition_tree.
113111
114112
Parameters
@@ -138,9 +136,6 @@ def condition_tree(config: dict,
138136
None, and the component's arguments are changed, the component will
139137
be re-mounted in the Streamlit frontend and lose its current state.
140138
Can also be used to access the condition tree through st.session_state.
141-
allow_unsafe_jscode: bool
142-
Allows jsCode to be injected in gridOptions.
143-
Defaults to False.
144139
145140
Returns
146141
-------
@@ -159,28 +154,18 @@ def condition_tree(config: dict,
159154

160155
config['fields'] = fields
161156

162-
if allow_unsafe_jscode:
163-
walk_config(config, lambda v: v.js_code if isinstance(v, JsCode) else v)
164-
165-
try:
166-
output_tree, component_value = _component_func(
167-
config=config,
168-
return_type=return_type,
169-
tree=tree,
170-
key='_' + key if key else None,
171-
min_height=min_height,
172-
placeholder=placeholder,
173-
always_show_buttons=always_show_buttons,
174-
default=['', ''],
175-
allow_unsafe_jscode=allow_unsafe_jscode,
176-
)
177-
178-
except MarshallComponentException as e:
179-
# Uses a more complete error message.
180-
args = list(e.args)
181-
args[0] += ". If you're using custom JsCode objects on config, ensure that allow_unsafe_jscode is True."
182-
e = MarshallComponentException(*args)
183-
raise (e)
157+
walk_config(config, lambda v: v.js_code if isinstance(v, JsCode) else v)
158+
159+
output_tree, component_value = _component_func(
160+
config=config,
161+
return_type=return_type,
162+
tree=tree,
163+
key='_' + key if key else None,
164+
min_height=min_height,
165+
placeholder=placeholder,
166+
always_show_buttons=always_show_buttons,
167+
default=['', ''],
168+
)
184169

185170
if return_type == 'queryString' and not component_value:
186171
# Default string that applies no filter in DataFrame.query

0 commit comments

Comments
 (0)