mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
start of interface with jQuery for DOM impl
This commit is contained in:
43
packages/ui/backend.js
Normal file
43
packages/ui/backend.js
Normal file
@@ -0,0 +1,43 @@
|
||||
UI = {};
|
||||
|
||||
if (Meteor.isClient) {
|
||||
|
||||
// XXX in the future, make the jQuery adapter a separate
|
||||
// package and make the choice of back-end library
|
||||
// configurable. Adapters all expose the DomBackend interface.
|
||||
|
||||
if (! Package.jquery)
|
||||
throw new Error("Meteor UI jQuery adapter: jQuery not found.");
|
||||
|
||||
var $ = Package.jquery.jQuery;
|
||||
|
||||
var DomBackend = {
|
||||
parseHTML: function (html) {
|
||||
// Return an array of nodes.
|
||||
//
|
||||
// jQuery does fancy stuff like creating an appropriate
|
||||
// container element and setting innerHTML on it, as well
|
||||
// as working around various IE quirks.
|
||||
return $.parseHTML(html);
|
||||
},
|
||||
watchElement: function (elem) {
|
||||
$(elem).on('meteor_ui_domrange_gc', $.noop);
|
||||
},
|
||||
// Called when an element is removed from the DOM using the
|
||||
// back-end library directly, either by removing it directly
|
||||
// or by removing a parent.
|
||||
//
|
||||
// To use this, override it (set it).
|
||||
onRemoveElement: function (elem) {}
|
||||
};
|
||||
|
||||
// See http://bugs.jquery.com/ticket/12213#comment:23
|
||||
$.event.special.meteor_ui_domrange_gc = {
|
||||
teardown: function() {
|
||||
DomBackend.onRemoveElement(this);
|
||||
}
|
||||
};
|
||||
|
||||
UI.DomBackend = DomBackend;
|
||||
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
UI = {};
|
||||
|
||||
var removeNode = function (n) {
|
||||
// if (n.nodeType === 1 &&
|
||||
|
||||
@@ -11,7 +11,8 @@ Package.on_use(function (api) {
|
||||
api.use('ordered-dict');
|
||||
api.use('minimongo'); // for idStringify
|
||||
|
||||
api.add_files(['domrange.js']);
|
||||
api.add_files(['backend.js',
|
||||
'domrange.js']);
|
||||
});
|
||||
|
||||
Package.on_test(function (api) {
|
||||
|
||||
Reference in New Issue
Block a user