Gaia,
The global object exists a convention for creating modules that is
compatible across the browsers and Node.js. Node.js already provides an
object named global, so I just had to declare a new object in the browser
only code and populate each of these objects in similar ways. I would
also prefer to avoid populating the global scope with additional
references, but this way works universally and doesn't require any
external assets or build process to work.
I am using this code, (ace === undefined || ace.createEditSession ===
undefined), to suppress a conflict in the define function of require.js
because Ace will throw errors about this (even though it still appears to
work). I have just experimented with modifying my instance of Ace so that
it has a property named "prettydiffid" and examining for that instead of
"createEditSession". This appears to successfully suppress the error in
the same way. I will publish this update soon.
Austin
> Doing so, global is still not defined as it is defined only in the closure
> it was declared in.
> In order to have global defined it should be moved outside of the closure.
> I could have it work only as follows:
>
> var global = {};
> define([
> "sap/watt/lib/prettydiff/lib/csspretty",
> "sap/watt/lib/prettydiff/lib/safeSort",
> "sap/watt/lib/prettydiff/lib/csvpretty",
> "sap/watt/lib/prettydiff/lib/diffview",
> "sap/watt/lib/prettydiff/lib/jspretty",
> "sap/watt/lib/prettydiff/lib/markuppretty",
> "sap/watt/lib/prettydiff/prettydiff"
> ], function (csspretty, safeSort, csvpretty, diffview, jspretty,
> markuppretty, prettydiff) {
> ...
> var settings = {
> lang: "xml",
> inchar : "\t",
> insize: 1,
> html: false
> };
>
> var content = prettydiff(settings);
> ....
> });
>
> Still there are two issues:
> 1. I would like to avoid global (window scope) variables
> 2. For our case we do have ace, but prettydiff is not activated from ace.
> therefore it conflicts with ace condition in prettydiff.js line 2520:
> (ace === undefined || ace.createEditSession === undefined)
>
> Thanks,
> Gaia
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Pretty Diff" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
pretty-diff...@googlegroups.com.
> To post to this group, send email to
prett...@googlegroups.com.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/pretty-diff/085bc4da-6fe5-47a6-9749-d2e2181b4efc%40googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.
>