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

condition is not supported for IE #984

Open
yinbiao opened this issue Aug 8, 2018 · 7 comments
Open

condition is not supported for IE #984

yinbiao opened this issue Aug 8, 2018 · 7 comments

Comments

@yinbiao
Copy link

yinbiao commented Aug 8, 2018

Enhancement

As a user, when i use “radios-inline” to crontrol some text input to hidden,so i use "condition" in these text input, exp: condition: "model.absolute"

Expected behaviour

I expected it worked for ie, firefix, chrome

Actual behaviour

It actually worked for firefix, chrome, but it raise exception in IE8, it shows:
TypeError: Object not supported “getAttribute" attribute or method

Debug:
condition: function(args) {
174 // Do we have a condition? Then we slap on an ng-if on all children,
175 // but be nice to existing ng-if.
176 console.log(args);
177 if (args.form.condition) {
178 var evalExpr = 'evalExpr(' + args.path +
179 '.condition, { model: model, "arrayIndex": $index})';
180 if (args.form.key) {
181 var strKey = sfPathProvider.stringify(args.form.key);
182 evalExpr = 'evalExpr(' + args.path + '.condition,{ model: model, "arrayIndex": $index, ' +
183 '"modelValue": model' + (strKey[0] === '[' ? '' : '.') + strKey + '})';
184 }
185
186 var children = args.fieldFrag.children || args.fieldFrag.childNodes;
187 console.log(children);
188 for (var i = 0; i < children.length; i++) {
189 var child = children[i];
190 console.log(child);
191 var ngIf = child.getAttribute('ng-if');
192 child.setAttribute(
193 'ng-if',
194 ngIf ?
195 '(' + ngIf +
196 ') || (' + evalExpr + ')'
197 : evalExpr
198 );
199 }
200 }
201 },

In the ie console, it shows:
<NodeList length="2"></NodeList>
<p class="hz-help ($::form.htmlClasss$}" sf-field="3" ng-bind-html="form.helpvalue"></p>
EmptyTextNode
TypeError: Object not supported “getAttribute" attribute or method

@yinbiao
Copy link
Author

yinbiao commented Aug 8, 2018

I added a conditional judgment, then it worked in IE:
if(child.getAttribute){
var ngIf = child.getAttribute('ng-if');
child.setAttribute(
'ng-if',
ngIf ?
'(' + ngIf +
') || (' + evalExpr + ')'
: evalExpr
);
}

@Anthropic
Copy link
Member

Anthropic commented Aug 8, 2018

@yinbiao thanks for taking the time to make a clear issue. Can you confirm when you say it worked that it shows and hides the field as expected or just doesn't error? It looks above that the added if condition would exclude the code from running in IE at all wouldn't it?

@scottux
Copy link
Contributor

scottux commented Aug 12, 2018

@yinbiao Any particular version of IE?

@scottux
Copy link
Contributor

scottux commented Aug 12, 2018

And this is weird, it looks like it is failing because it is trying to call getAttribute on an EmptyTextNode. Maybe we should skip those.

@edclements
Copy link
Contributor

I think this is a duplicate of #903 which is fixed in 0.8.14

@yinbiao
Copy link
Author

yinbiao commented Oct 21, 2018

@Anthropic yes , it not running on IE, but shows and hides the field as expected and doesn't error,

@yinbiao
Copy link
Author

yinbiao commented Oct 21, 2018

@scottux I only tested on a version of the IE browser,it should be ie 8

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

4 participants