예제 #1
0
        private void OnHandleNodeScript(Event evt, string handlerCode)
        {
            //the code in the 'href' attribute of the anchor element have to be executed asynchronously
            var async = evt.Type == "click" && evt.CurrentTarget is HtmlAnchorElement anchor &&
                        string.IsNullOrEmpty(anchor.GetAttribute("onclick"));

            handlerCode = handlerCode.Trim();
            if (handlerCode.Last() != ';')
            {
                handlerCode += ";";
            }

            if (async)
            {
                Task.Run(
                    () =>
                {
                    lock (_document)
                        return(_scriptExecutor.EvalFuncAndCall("function (event){" + handlerCode + "}", evt.Target, evt));
                });
            }
            else
            {
                _scriptExecutor.EvalFuncAndCall("function (event){" + handlerCode + "}", evt.Target, evt);
            }
        }
예제 #2
0
        private void OnHandleNodeScript(Event evt, string handlerCode)
        {
            handlerCode = handlerCode.Trim();
            if (handlerCode.Last() != ';')
            {
                handlerCode += ";";
            }

            _scriptExecutor.EvalFuncAndCall("function (event){" + handlerCode + "}", evt.Target, evt);
        }