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

Globalize jquery enhanced #623

Merged
merged 11 commits into from Mar 9, 2016
Merged

Globalize jquery enhanced #623

merged 11 commits into from Mar 9, 2016

Conversation

marcoscaceres
Copy link
Member

See commit list... I'm going to break this up into several PRs where I can.

@@ -0,0 +1,173 @@
define(["jquery","core/utils"], function($, utils) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a straight copy and paste from core/utils (where this code used to live). This code does not require review.

@marcoscaceres
Copy link
Member Author

Actually, I'm just going to annotate the code. As it's not as many changes as it looks.



[],
function () {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is where I ripped out the additions to JQuery from.

@marcoscaceres
Copy link
Member Author

Ok, finished annotations... ready for review.

@halindrome
Copy link
Contributor

I am reviewing this. Trying to be careful though.

@marcoscaceres
Copy link
Member Author

@halindrome really appreciate your time, thoroughness, help, and support! Your ideas are vastly improving what we are doing here.

@halindrome
Copy link
Contributor

Question - do you think this version fixes the general problem that our utils.js methods are not exposed to jquery extended objects when they are used in extensions? 'Cause my testing shows that getDfnTitles, for example, is not a method on a jquery extended object in a JS file loaded by a respec-enabled page.

@marcoscaceres
Copy link
Member Author

@halindrome, it should fix it. It literally just puts the extended jQuery into the window object before any of the plugins run.

getTextNodes(this[0]);
return textNodes;
};
window.$ = $;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@halindrome here be the magic!!!!! 🌟

@marcoscaceres
Copy link
Member Author

@marcoscaceres
Copy link
Member Author

An extension can also define(["jquery-enhanced"]) ... I even think that is they ask for just "jquery", they will also get the enhanced, as the enhanced one is just enhancing the jQuery singleton.

@halindrome
Copy link
Contributor

I think we are talking past one another. Before we started messing with this, tne utils.js module pushed a bunch of methods into the jquery function prototype so that they were all added to any jquery objects that are later created. So, when data-oninclude is defined that method will be called and jquery already has the extensions that permit easy integration with respec. That is not currently happening in this branch.

Extension scripts don't use require, and in any event there are tons of them out there. We can't ask them to all go change something in order to start working again.

@halindrome
Copy link
Contributor

Just to be clear - these extensions don't ASK for anything. They are just snippets of JS that get run within the context of ReSpec because it just works.

@marcoscaceres
Copy link
Member Author

Just to be clear - these extensions don't ASK for anything. They are just snippets of JS that get run within the context of ReSpec because it just works.

Understood. They don't need to ask. It will just work* (terms and conditions apply).

  • so long as they at least wait for isRespecReady or use the respecEvents thing.

@halindrome
Copy link
Contributor

Well - in the case where I am testing my method is called from the data-oninclude handler and the methods are not htere. Check out http://dev.spec-ops.io/webpayments-ig/VCTF/use-cases - it loads from this branch's build of respec.

@marcoscaceres
Copy link
Member Author

@halindrome, that version of ReSpec seems to be wrong (or didn't build?). It's missing this code. See, in particular, "profile-w3c-common.js". The code from this PR is not there?

@halindrome
Copy link
Contributor

yikes..... weird. testing

@marcoscaceres
Copy link
Member Author

@halindrome, in particular:

deps: ["core/jquery-enhanced", "Promise"]

is not there. And neither is the core/jquery-enhanced.js file.

@marcoscaceres
Copy link
Member Author

In other news! YAY! the sourcemap work just came in handy... in even other news, it's 4:30 am, of shit I better got to sleep! 👍

@marcoscaceres
Copy link
Member Author

*oh

@marcoscaceres
Copy link
Member Author

Just to show it works for me locally (everything is there):

screenshot 2016-03-10 04 35 36

Did you do? ./tools/build-w3c-common.js 💤 😴

@halindrome
Copy link
Contributor

Okay - no idea why it had not built when I changed branches. I do note that it is complaining about trying to load node_modules/promise-polyfill/Promise.js from the built version. I will try adding that to collection of required components that need to be included in the build. But yes, I can confirm that the object is extended!

Get some sleep.

@marcoscaceres
Copy link
Member Author

I do note that it is complaining about trying to load node_modules/promise-polyfill/Promise.js from the built version.

Can you please post a new bug with the error? That should only happen if it's missing from your node_modules dir, or something is not right in the builder. I'm not seeing that error locally here.

@halindrome
Copy link
Contributor

I will do. I do see that there is a dependency on it in that core/jquer-enhanced requires Promise, but we never load hqyer-enhanced in the profile-w3c-common.js file

@halindrome
Copy link
Contributor

Oh - and otherwise LGTM.

@marcoscaceres
Copy link
Member Author

Confirmed... it is going to the network for Promise.js. My thought is to just remove it, as all the browsers we target support it: http://caniuse.com/#search=Promise

@halindrome
Copy link
Contributor

Huh. Remember people use this for editors drafts and we have no control at all who revirews those. Including people who use older user agents. ReSpec - it's not just for development any more. (tm)

@marcoscaceres
Copy link
Member Author

@halindrome, sure, but we have to cut off somewhere. Promises have been natively supported in browsers for over a year, and all browsers are now evergreen. It seems highly unlikely people reading specs (specially ed drafts) won't be running a browser that is at most 3 months old.

@halindrome
Copy link
Contributor

I am willing to try this - I just note for the record that it could bite us in the ass. In particular with Windows users who have not moved to Windows 10 and for whatever reason use IE.

@marcoscaceres
Copy link
Member Author

Let's see what happens. If it's bad, we can quickly add the poly back.

@halindrome
Copy link
Contributor

Assuming this passes I am comfortable with you merging and pushing a new release.

@marcoscaceres
Copy link
Member Author

Ha! I think ./tests/headless.js just ruined the party.

@halindrome
Copy link
Contributor

you're right. I had this problem the other day too. UGGH

@marcoscaceres
Copy link
Member Author

Backed out the last commit.

@marcoscaceres
Copy link
Member Author

Ok, will merge this after it turns green and figure out why Promise is not being inserted tomorrow (unless you want to have a look). The respecIsReady promise is also ready to merge, I hope.

@halindrome
Copy link
Contributor

works for me. I will play with it a little in a new (local) branch once it is all merged.

marcoscaceres pushed a commit that referenced this pull request Mar 9, 2016
@marcoscaceres marcoscaceres merged commit da7b6be into develop Mar 9, 2016
@marcoscaceres marcoscaceres deleted the globalize_jquery_enhanced branch March 9, 2016 18:20
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

Successfully merging this pull request may close these issues.

None yet

2 participants