Fixing AngularJS 1.2.0 [$parse:isecprv] errors - javascript

AngularJS 1.2.0 just got released, and there's an instant problem for CounchDB and MongoDB users:
When trying to access some JSON data preceded by an underscore, like {{data._id}} Angular 1.2.0 gives the following error:
Error: [$parse:isecprv]
There is discussion about this here on the docs.
Is there a way to disable this 'feature', or overcome it?

To disable this 'feature' in 1.2.0, comment out lines 9097 till 9101. These 5 lines are responsible for Error: [$parse:isecprv]:
if (name.charAt(0) === '_' || name.charAt(name.length-1) === '_') {
throw $parseMinErr('isecprv',
'Referencing private fields in Angular expressions is disallowed! Expression: {0}',
fullExpression);
}

It looks like we'll need to wait until 1.2.1 has been released.
Nov 13 2013 Vojta said the following about this 'feature':
Guys, sorry for the troubles this change caused. This "feature" was
mostly for people using Closure compiler and Google JS style, but I
didn't realize that many people were relying on accessing _*
properties in templates. For now we are reverting that change
(4ab16aa).
We gonna release 1.2.1 (which will contain this "fix") within next
days.
The main outcome of this issue is: we should not put any breaking
changes into RC. Lesson learned.
Update - Nov 15, 2013: AngularJS 1.2.1 underscore-empathy reverts hiding "private" properties.
We introduced "private" properties (for properties prefaced with an
underscore) in 1.2 thinking that this would be a fairly
uncontroversial change. Oops! Apologies (and thank you) to the folks
who filed bugs alerting us to the larger consequences in your code of
making this breaking change. We've reverted this feature.

Related

setSrc for IFRAME in Dynamics CRM unified form is not working

I am following below walkthrough by J. Lattimar to add Documents navigation in CRM form tab. It was working fine in classical forms, but for unified forms the steps are not working and instead throw exception like An Error as has occurred. Any idea how to get this working?
https://jlattimer.blogspot.com/2017/01/show-sharepoint-documents-on-main-form.html
Xrm.Page is deprecated, so you'll need to update this JS. Start here:
https://learn.microsoft.com/en-us/dynamics365/get-started/whats-new/customer-engagement/important-changes-coming
First of all, this is unsupported approach we are following, author clearly called it out.
In UCI why it broke - someone did investigation already
Replacing Xrm.Page.context.getQueryStringParameters().etc
with "10069" ended up resolving this and currently works within UCI and Classic interfaces.
Actually couple of things to take care.
Like Hoffma said - Xrm.Page is deprecated, you have to rewrite the code to refer formContext from executionContext
Xrm.Page.context.getQueryStringParameters() is not containing the etc now, that's why breaking in UCI. You can supply the entity type code (etc) in the url manually

Vue is extremely slow to compile this HTML template in dev mode

I am using a template app setup that I bootstrapped with vue CLI. I have one component that has 20 nested div tags. Compiling such a component in dev mode takes around 10 seconds. The deeper I nest the html elements the longer it takes and the time grows exponentially.
Is this behaviour normal? Is there a way to improve compilation time?
Here's an example: https://gist.github.com/dmitrybelyakov/ed64145624f42188372500018671eb0f
Answering my own question here: following the link to this SO post by Bennett Dams, some people already investigated this, and there is an issue with prettier library that gets used internally by vue-loader, specifically their template compiler utils. The issue has been reported to prettier team here and there, but it hasn't been fixed as of yet.
Because of that, vue template compiler comes with this issue out of the box. So if you nest ~30 html elements you can basically halt your compiler (only happens in dev mode).
Same goes for when you have less nested (~4-5) levels elements, but a few of them, in which case compilation gets progressively slower and reload/inject time suffers which makes waiting for your component to reload a pain.
I have reported this issue to vue-loader team here #1426 asking for a config option to disable use of prettier, so hopefully it will get looked at.
UPDATE: this should now be fixed in vue-loader via prettify config option that was added: https://github.com/vuejs/vue-loader/issues/1426
OLD SOLUTION:
For the moment though, the only fix is to edit node_modules/#vue/component-compiler-utils/dis/compileTemplate.js to comment out the line (should be around line 97) like so:
//code = prettier.format(code, { semi: false, parser: 'babylon' });

Strage behaviour using Knockout.js 3.2.0, shift is undefined

This one's been a real hair-puller.
I moved some divs into templates without altering any ko's datacontext, and all of a sudden I had the dreaded "undefined is not a function" in template.
Turns out it wasn't something related to a missing observable, but something internal to ko:
Looks like continuousNodeArray is not a plain-old array but it's a jQuery object array (I assume in this particular instance only, as I believe it should be a plain-old array).
So I'm curious to know if this is a Knockout.js bug or something in my templates triggering this behaviour. I solved this by adding the following:
jQuery.fn.shift = [].shift;
But I'm sure there must be something else going on. Any clue?
This is known and not recently (Oct 8) fixed bug when you are using jquery.tmpl as a templating engine.
See on github: Fix error in fixUpContinuousNodeArray when using jquery.tmpl
So if you check the latest source you will see now that splice is used instead of shift:
However it is not included in the latest version (3.2.0) so you properly should stick to your workaround until a new version comes out.

Ember and Syn integration

I'm having trouble integrating bitovi syn (link), Rails 3 (asset pipeline), Ember and qunit. I want to use syn for browser simulation for testing purposes. Has anyone done this, if so, how?
I'm using the version of syn that was released 11 Mar 2014. When I load it into my app, two things happen:
I get a global failure in qunit that says "TypeError: 'undefined' is not an object (evaluating 'Syn.schedule')", (around this line: syn.js?body=1:1084)
and
A div with a form is added to my application.
I'm using qunit for the most part, and I dabbled with using YUI to do browser simulation but it isn't working quite the way I had expected it to. I'd really like to use Syn, but I don't understand why it's not working.
In attempting to get it work, I tried adding this line to the top of the syn.js file:
window.Syn = { schedule: function (fn, ms) { Ember.run.later(window, fn, ms); } };
but it didn't do anything much at all.
I'd read on this pull request: https://github.com/bitovi/syn/pull/28 that I could add that piece of code to mount it in a fashion to work with Ember.
Any help would be greatly appreciated!
So the thing here was simply to load Syn at the bottom of the page. It's potentially a bit broken at the moment in the case where you want to load it in the head (which I probably shouldn't have been doing anyway, but still!) :)

undefined method `invalid_element_errors' in capybara-webkit

first off I'd like to point out that I'm a bit new at this and thus hope this post will be understandable.
Gems:
rails (2.3.11
nokogiri (1.5.4)
cucumber (1.1.9)
capybara (1.1.2)
copybara-webkit (0.12.1)
Right now I'm doing a project were I'm trying to use cucumber for integration testing of a rails web application.
Since the web-application relies heavily on javascript and ajax I want to use a capybara driver that can handle this. (I just realized :rake_test does not) But I don't want to have a browser window pop up all the time as that will take time.
So I opted on capybara-webkit.
But now that I changed driver, by setting the javascript driver for capybara in my env.rb, I keep getting a annoying error all the time:
undefined method `invalid_element_errors' for #<Capybara::Driver::Webkit:0x9c50bf8> (NoMethodError)
./features/step_definitions/some_steps.rb:37
My code at that line:
>> 35 select("something", :from => find("select[class='class_name']")[:id])
>> 36 click_link('javascript_link')
>> 37 click_link('another_javascript_link')
I'm using a find in line 35 since the id is dynamic.
Now it seems like the problem is actually the find method since if I add another find with known id above this point I'm getting the same error thrown on me on that line instead.
How do I get rid of this problem so I can use capybara-webkit?
I've heard somewhere that this is a problem in the actual driver and that a fix is available at the github masterbranch and that you somehow can link your gem there?
If so can anybody explain how to do it?
I've suffered this problem too. It's a capybara-webkit bug: the 0.12.1 version does not have the invalid_element_errors method.
There was a pull request a few months ago with the fix, but it wasn't merged (https://github.com/thoughtbot/capybara-webkit/pull/288). Now they have added the method in the master branch, so you have to use the git repository:
gem 'capybara-webkit', :git => 'git://github.com/thoughtbot/capybara-webkit'
Try it and see if it works for you :).

Categories