Git Product home page Git Product logo

Comments (4)

wytrych avatar wytrych commented on August 15, 2024

It's quite standard practice to reference global variables with window when using code wrapped in IIFE. Unless of course you want to use it outside of a brower context, but that's not the case here. The reason is that when using window explicitly, we are sure we're referencing the global angular instead of some random variable that might have been declared before the IIFE. What do you find odd about it?

from angular-bind-html-compile.

david-mark avatar david-mark commented on August 15, 2024

from angular-bind-html-compile.

wytrych avatar wytrych commented on August 15, 2024

Still, I don't understand what is wrong with this pattern and why would you like it to be changed?

from angular-bind-html-compile.

david-mark avatar david-mark commented on August 15, 2024

First of all, the reference to the - window - object is in the global scope. As there is only one object in the scope chain, which is the Global Object, there's no reason to reference - angular - this way. It's just a pointless (and odd) dot operation.

Second, in the global scope, the - this - object references the Global Object, so you could have used that instead of the - window - host object. There's never a reason to use a host object to reference a global variable; if there were, the language would clearly be broken.

As for wanting it changed, I really don't care. Just thought I'd point out some odd choices in the code. On an unrelated note, it's no longer used in my current project.

from angular-bind-html-compile.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.