Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should not throw error when trying to emit scheduled stateChanged after disposed', function(done) {
var state = createStateInstance();
state.key1 = 10;
state.dispose();
async.nextTick(function() {
done();
});
});
it('should not throw error when trying to emit scheduled attrsChanged after disposed', function(done) {
var attr = createAttributeInstance();
attr.attr1 = 10;
attr.dispose();
async.nextTick(function() {
done();
});
});
static runScript(script, opt_callback, opt_appendFn) {
const callback = function() {
opt_callback && opt_callback();
};
if (script.type && script.type !== 'text/javascript') {
async.nextTick(callback);
return;
}
exitDocument(script);
if (script.src) {
return globalEval.runFile(script.src, opt_callback, opt_appendFn);
} else {
async.nextTick(callback);
return globalEval.run(script.text, opt_appendFn);
}
}
scheduleBatchEvent_(changeData) {
if (!this.scheduledBatchData_) {
async.nextTick(this.emitBatchEvent_, this);
this.scheduledBatchData_ = object.mixin({
changes: {}
}, this.eventData_);
}
const name = changeData.key;
const changes = this.scheduledBatchData_.changes;
if (changes[name]) {
changes[name].newVal = changeData.newVal;
} else {
changes[name] = changeData;
}
}
static runScript(script, opt_callback, opt_appendFn) {
const callback = function() {
opt_callback && opt_callback();
};
if (script.type && script.type !== 'text/javascript') {
async.nextTick(callback);
return;
}
exitDocument(script);
if (script.src) {
return globalEval.runFile(script.src, opt_callback, opt_appendFn);
} else {
async.nextTick(callback);
return globalEval.run(script.text, opt_appendFn);
}
}
if (
style.rel &&
style.rel !== 'stylesheet' &&
style.rel !== 'canonical' &&
style.rel !== 'alternate'
) {
async.nextTick(callback);
return;
}
if (
style.tagName === 'STYLE' ||
style.rel === 'canonical' ||
style.rel === 'alternate'
) {
async.nextTick(callback);
} else {
once(style, 'load', callback);
once(style, 'error', callback);
}
if (appendFn) {
appendFn(style);
} else {
document.head.appendChild(style);
}
return style;
}
static runScriptsInElement(element, opt_callback, opt_appendFn) {
const scripts = element.querySelectorAll('script');
if (scripts.length) {
globalEval.runScriptsInOrder(scripts, 0, opt_callback, opt_appendFn);
} else if (opt_callback) {
async.nextTick(opt_callback);
}
}
scheduleBatchEvent_(attrChangeData) {
if (!this.scheduledBatchData_) {
async.nextTick(this.emitBatchEvent_, this);
this.scheduledBatchData_ = {
changes: {}
};
}
var name = attrChangeData.attrName;
var changes = this.scheduledBatchData_.changes;
if (changes[name]) {
changes[name].newVal = attrChangeData.newVal;
} else {
changes[name] = attrChangeData;
}
}
const callback = function() {
if (opt_callback && ++loadCount === styles.length) {
async.nextTick(opt_callback);
}
};
for (let i = 0; i < styles.length; i++) {